WPF data binding issue .
Posted
by
Praveen
on Stack Overflow
See other posts from Stack Overflow
or by Praveen
Published on 2011-01-09T11:49:04Z
Indexed on
2011/01/09
11:53 UTC
Read the original article
Hit count: 153
wpf
Hi All,
I have a wpf app and there i simply have a dock panel and inside dock panel i have a textblock.
I want to bind the text property of textblock to my custom objects property but that' not working.
I think i am missing something here but don't know what.
Here is the code snippet.
<TextBlock Text="{Binding Source=myDataSource, Path=ColorName}"/>
</DockPanel>
My custom class.
class MyData
{
public string ColorName { get; set; }
}
and main window constructor..
public partial class MainWindow : Window
{
MyData myDataSource;
public MainWindow()
{
InitializeComponent();
myDataSource = new MyData { ColorName = "Red" };
}
}
© Stack Overflow or respective owner