0
私はテキストブロックとテキストボックスを持つ非常に単純なMVVM Lightアプリケーションを持っています。私がやろうとしているのは、MVVM Light Toolkitとデータバインディングを使ってtextblockの値をテキストボックスの値に設定することです。プログラムを実行すると、テキストブロックのテキストは更新されません。MVVMライトのテキストボックスにテキストブロックをバインドします
private string _name = "Test Name";
public string Name
{
get
{
return _name;
}
set
{
_name = value;
RaisePropertyChanged("NameChanged");
}
}
ここにXAMLがあります。 「テスト名」は正しく表示されますが、テキストボックスの値は変更されません。 のTextBlock:
<TextBlock x:Name="NameTitle"
Text="{Binding Name}"
Margin="-3,-8,0,0"/>
のTextBox:
<TextBox Text="{Binding Name, Mode="TwoWay"}" x:Name="tb"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="40" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<commands:EventToCommand Command="{Binding Name}"
CommandParameter="{Binding Text, ElementName=tb}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>