kender_a
November 18th, 2009, 02:44 AM
Colleagues,
I have a text box which binds to data:
<TextBox x:Name="textBox1" Text="{Binding Path=Comments}" Width="200" Margin="0,4" />
If Comments is declared as a property, the binding works:
public int Comments { get; set; }
However, if Comments is declared as a field, the binding doesn’t work:
public int Comments;
I haven’t seen an example where a control was bound to a field, but I haven’t seen any indication that it’s a bad practice or not possible.
- Nick
I have a text box which binds to data:
<TextBox x:Name="textBox1" Text="{Binding Path=Comments}" Width="200" Margin="0,4" />
If Comments is declared as a property, the binding works:
public int Comments { get; set; }
However, if Comments is declared as a field, the binding doesn’t work:
public int Comments;
I haven’t seen an example where a control was bound to a field, but I haven’t seen any indication that it’s a bad practice or not possible.
- Nick