こんにちは、誰かが新鮮な目を持っていて、ここで問題を特定するのを手伝ってくれることを願っています。プリズムとMVVMパターンを使用して小さなアプリを作成しようとしています。この時点まではすべてうまく機能していました。私のコマンドは引数で適切に実行されていますただし、ここの TextBlock は、ビューモデルから CurrentUserKey プロパティにバインドされていません。
誰にもアイデアはありますか?前もって感謝します...
LoginView.xaml (簡潔にするために関連部分のみ) ...
<Grid DataContext="{Binding Path=., Source={StaticResource viewModel}}">
<Grid Margin="10">
<Label VerticalAlignment="Center" HorizontalAlignment="Right">Enter your Key:</Label>
<TextBlock Name="txtUserKey" Text="{Binding Path=CurrentUserKey}" Margin="2" />
<Button cal:Click.Command="{Binding GenericButtonClick}" cal:Click.CommandParameter="7">7</Button>
<Button cal:Click.Command="{Binding GenericButtonClick}" cal:Click.CommandParameter="8">8</Button>
<Button cal:Click.Command="{Binding GenericButtonClick}" cal:Click.CommandParameter="9">9</Button>
...
</Grid>
...
LoginViewModel.cs
public class LoginViewModel : ViewModelBase
{
public LoginViewModel()
{
GenericButtonClick = new DelegateCommand<string>(GenericButtonClickHandler);
}
private void GenericButtonClickHandler(string argument)
{
if (argument.Length < 2) {
CurrentUserKey += argument;
}
RaisePropertyChangedEvent("GenericButtonClick");
}
public string CurrentUserKey { get; set; }
private ICommand GenericButtonClick { get; set; }
}
ViewModelBase.cs
public class ViewModelBase:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChangedEvent(string Property_name)
{
if (Property_name == null) return;
PropertyChangedEventArgs e = new PropertyChangedEventArgs(Property_name);
PropertyChanged(this, e);
}
}