Hi,
I figure out a solution. I do not know if it is the best one (I am almost 100% that is not) but ir works :D
Heres the code.
XAML
<usercontrol x:class="WpfCoWorker.CoWorkerSeparatorControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:osc="clr-namespace:WpfCoWorker"
Name="coworkercontrol"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<border name="mainborder" removed="{Binding ElementName=colorpicker, Path=SelectedBrush}">
<grid>
<grid.columndefinitions>
<columndefinition width="*" />
<columndefinition width="22" />
</grid.columndefinitions>
<textbox name="texbox">
Margin="0"
Padding="0"
Grid.Column="0"
Height="Auto"
Background="{Binding ElementName=colorpicker, Path=SelectedBrush}"
Text="{Binding Text, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<osc:comboboxcolorpicker x:name="colorpicker" xmlns:osc="#unknown">
SelectedColor="White"
ColorChanged="colorpicker_ColorChanged"
HorizontalAlignment="Left"
Grid.Column="1"/>
</grid>
</border>
</usercontrol>
And de C# code
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace WpfCoWorker
{
public partial class CoWorkerSeparatorControl : UserControl
{
public String IText
{
get { return this.texbox.Text; }
}
public Color IColor
{
get { return this.colorpicker.SelectedColor; }
}
public String Text
{
get { return (String)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(String),
typeof(CoWorkerSeparatorControl), new PropertyMetadata(""));
public Color BckColor
{
get { return (Color)GetValue(BckColorProperty); }
set { SetValue(BckColorProperty, value); }
}
public static readonly DependencyProperty BckColorProperty =
DependencyProperty.Register("BckColor", typeof(Color),
typeof(CoWorkerSeparatorControl), new PropertyMetadata(Colors.Transparent));
public CoWorkerSeparatorControl()
{
InitializeComponent();
}
}
}
The
osc:ComboBoxColorPicker
is this control: http://www.codeproject.com/Articles/34376/Small-ColorPicker-for-WPF
I hope this helps someone.
Best regards
Filipe Marques