인사말, 잘만되면 누군가가 더 신선한 눈을 가졌고 여기서 문제를 정확하게 지적 할 수 있습니다. 저는 프리즘과 MVVM 패턴으로 작은 응용 프로그램을 만들려고 노력하고 있습니다. 멋지게이 시점까지는 내 명령이 인수로 제대로 실행되지만 여기있는 TextBlock은 ViewModel의 CurrentUserKey 속성에 바인딩되어 있지 않습니다.ViewModel 속성 (Prism)에 대한 WPF 데이터 바인딩에 대한 도움말
아무도 아이디어가 있습니까? 사전에 덕분에 ...
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);
}
}
를 참조하십시오 당신이 Visual Studio에서 디버그 창에 그 효과에 약간의 출력을 얻을 수 있습니다 바인딩 아니에요 경우 - 당신이 있음을 붙여 넣을 수 있습니다 여기도? –
내 n00bness, 디버그 창 또는 출력 창에 죄송합니다? 디버그 창에서 어떤 객체를 감시해야하는지 지정할 수 있습니까? thnx – Geo