I have a question about how bindings work in WPF.
If i have a viewmodel with a property like this:
private string testString;
public string TestString
{
get { return testString; }
set { testString = value; }
}
Then if I bind it to a xaml with something like this:
<TextBlock
Text="{Binding Path=TestString, Mode=TwoWay}"
Foreground="Red"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Calibri"
FontSize="24"
FontWeight="Bold">
</TextBlock>
It works... Nothing new here.
However, if I remove the getters and setters from the test string and end up with something like this:
public string TestString;
The very same binding doesn't work. I have no idea why this occurs because to me, it's equivalent a public attribute to a public attribute with custom get and set.
Can someone shed some light on this subject for me? :)
TYVM in advance!!
PS: Sorry about my syntax highlight. I just can't figure how to work with the code block.