M
mick
Been struggling with this for ages so you are my last resort before my head
explodes -
Given this code behind file below how would I reference the myColors object
in the XAML file
for binding purposes, something along he lines of -
<Rectangle Fill="{Binding Source=myColors2, Path=SelectedColorString}" ....>
I'm a beginner with WPF so simple as possible please![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
//--------- Code behind ----------------
namespace BindingExamples
{
public partial class MainWindow : Window
{
MyColors myColors = new MyColors();
public MainWindow()
{
InitializeComponent();
}
}
public class MyColors
ependencyObject
{
public static readonly DependencyProperty
SelectedColorStringProperty =
DependencyProperty.Register("SelectedColorString",
typeof(string), typeof(MyColors));
public string SelectedColorString
{
get
{
return (string)GetValue(SelectedColorStringProperty);
}
set
{
SetValue(SelectedColorStringProperty, value);
}
}
public MyColors(){}
}
}
mick
explodes -
Given this code behind file below how would I reference the myColors object
in the XAML file
for binding purposes, something along he lines of -
<Rectangle Fill="{Binding Source=myColors2, Path=SelectedColorString}" ....>
I'm a beginner with WPF so simple as possible please
![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
//--------- Code behind ----------------
namespace BindingExamples
{
public partial class MainWindow : Window
{
MyColors myColors = new MyColors();
public MainWindow()
{
InitializeComponent();
}
}
public class MyColors
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
{
public static readonly DependencyProperty
SelectedColorStringProperty =
DependencyProperty.Register("SelectedColorString",
typeof(string), typeof(MyColors));
public string SelectedColorString
{
get
{
return (string)GetValue(SelectedColorStringProperty);
}
set
{
SetValue(SelectedColorStringProperty, value);
}
}
public MyColors(){}
}
}
mick