을 클릭 바인딩 할 수 없습니다 . 이것은 명령 작업을하기위한 테스트 응용 프로그램입니다.왜 내 실버 버튼이 난 그냥 버튼 내가 뷰 모델에 만든 간단한 명령을 클릭 결합하기 위해 노력하고있어 실버 라이트 3 프리즘 간단한 테스트 응용 프로그램을 가지고 프리즘 DelegateCommand
System.Windows.Data Error: BindingExpression path error: 'MyCommand' property not found on 'Bind1.ShellViewModel' 'Bind1.ShellViewModel' (HashCode=8628710). BindingExpression: Path='MyCommand' DataItem='Bind1.ShellViewModel' (HashCode=8628710); target element is 'System.Windows.Controls.Button' (Name=''); target property is 'Command' (type 'System.Windows.Input.ICommand')..
가 여기 내 쉘 뷰의 :
<UserControl
x:Class="Bind1.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Commands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<TextBlock Text="Hello World!"></TextBlock>
<Button Content="{Binding ButtonLabel}" Commands:Click.Command="{Binding Path=MyCommand}" />
</StackPanel>
</Grid>
</UserControl>
뷰의 생성자에서 (내가 ViewModel을 인스턴스화 내가 그것을 실행하면 나는보기가 명령을 찾을 수 있다고 말해 바인딩 오류 나는) ... 아직 용기를 사용하는 방법에 대한 걱정 안 해요 :
: 여기public partial class ShellView : UserControl
{
public ShellView()
{
InitializeComponent();
DataContext = new ShellViewModel();
}
}
내 뷰 모델입니다
public class ShellViewModel
{
public string ButtonLabel { get { return "DoIt!!"; } }
public DelegateCommand<object> MyCommand = new DelegateCommand<object>(ExecuteMyCommand);
public static void ExecuteMyCommand(object obj)
{
Debug.WriteLine("Doit executed");
}
}
단추 레이블 바인딩이 제대로 작동하여보기에서 ViewModel OK를 찾을 수 있습니다.
왜 MyCommand를 찾을 수 없습니까? 나에게 화를 운전하는 것 - 나는 분명히 매우 잘못된 간단한 일을하고 ...
덕분에 많이.