I have a simply view:
<Grid x:Name="LayoutRoot">
<TextBox Height="23" HorizontalAlignment="Left" Margin="66,66,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding Path=MainName,Mode=TwoWay}" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="66,142,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" Text="Space to tab :)" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="67,220,0,0" Name="textBox3" VerticalAlignment="Top" Width="120" Text="{Binding Path=Name}" />
</Grid>
And in ViewModel i have:
private string _mainName;
public string Name
{
get { return MainName; }
}
public string MainName
{
get { return _mainName; }
set
{
_mainName = value;
RaisePropertyChanged(MainName);
RaisePropertyChanged(Name);
}
}
When I change value in first textbox, then RaisePropertyChange are called, and while debugging I see that it enters me to getters of MainName and Name, but there is no change in textblock which has binded Name.
Why is that, and how to fix it?
Your
RaisePropertyChangedmethod calls don’t look right to me. The argument should be the name of the property, not the value. In other words, you should writeIf your properties had a type other than
string, you’d pick the error up quite quickly, since in that case your code would not compile.