Reputation: 6422
Where can I find some good documentation on data/element binding? My Google searches haven't turned much up. I had a custom class with two properties named Text and Value. When I tried binding a list to a listbox it wouldn't work. By chance I modifed my datatemplate from this
<TextBox Text="{Binding Text}"></TextBox>
to this
<TextBox Text="{Binding Path=Text}"></TextBox>
and then everything worked great. I need some indepth documenation/samples to data/element binding. I don't understand why some examples have the path
set whereas others do not. A full explanation of this, and all other nice to know tips would be much appreciated.
UPDATE
Here's the class I'm using. It's a simple helper class so I can translate the value/text of an enum into my listbox
public class Item
{
private string _Text = "Test";
public string Text
{
get { return _Text; }
set { _Text = value; }
}
private string _Value = "1";
public string Value
{
get { return _Value; }
set { _Value = value; }
}
}
Upvotes: 1
Views: 417
Reputation: 86698
In theory, your two binding examples are equivalent. The Path=
is optional if your path is the first part of the Binding clause, so if one of your examples behaved differently, it's either due to a bug in Silverlight or a change you made elsewhere without realizing it.
Here's the Silverlight documentation on Path: http://msdn.microsoft.com/en-us/library/cc645024(v=VS.95).aspx
Here's the Silverlight documentation for {Binding}
: http://msdn.microsoft.com/en-us/library/cc189022(VS.95).aspx
Upvotes: 1
Reputation: 1494
Not much, but here's a little to get you started:
MSDN documentation is here: http://msdn.microsoft.com/en-us/library/cc278072(VS.95).aspx
This page explains paths in slightly more detail: http://msdn.microsoft.com/en-us/library/system.windows.data.binding.path.aspx
As for why your example only works with the Path clause, I'll need to see the class you're binding to.
Upvotes: 2