Silverlight 3.0 Silverlight 3.0和MVVM模式
我正在写这篇文章,他们正在使用Silverlight4。 但是我使用的是Silverlight 3。但是对于button,我们无法找到命令 Command=“{Binding Path=DataContext.GetPerson,ElementName=LayoutRoot}”Silverlight 3.0 Silverlight 3.0和MVVM模式,silverlight-3.0,Silverlight 3.0,我正在写这篇文章,他们正在使用Silverlight4。 但是我使用的是Silverlight 3。但是对于button,我们无法找到命令 Command=“{Binding Path=DataContext.GetPerson,ElementName=LayoutRoot}” <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="53,112,0,0" Name="button1"
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="53,112,0,0" Name="button1"
VerticalAlignment="Top" Width="75" Command="{Binding Path=DataContext.GetPerson, ElementName= LayoutRoot }"
CommandParameter="{Binding Path=Age, ElementName=hi}" />
那么在Silverlight3中,我应该怎么做才能获得按钮的这个命令属性呢
任何帮助都很好命令是将操作与控件(例如按钮)关联的可绑定方式。 该命令控制两件事:
- 是否可以执行
- 执行时该怎么办
此外,此按钮将参数传递给命令(CommandParameter),您必须手动处理传递此参数的操作您可以使用类似的框架,将相关dll添加到项目中,然后向页面顶部添加引用,如下所示
xmlns:prism="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
然后在按钮上声明监狱属性
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="53,112,0,0" Name="button1"
VerticalAlignment="Top" Width="75" Command="{Binding Path=DataContext.GetPerson, ElementName= LayoutRoot }"
prism:Click.Command={Binding SomeCommand}
prism:Click.CommandParameter="{Binding Path=Age, ElementName=hi}" />