【发布时间】:2010-10-29 12:03:44
【问题描述】:
我有一个很奇怪的问题。在我的 WP7 应用程序中,我在其中定义了一个枢轴控件和一个项目模板(或在资源中,我尝试了两种方式,但仍然是同样的问题)。在模板中,我有一个定义了 EventToCommand 的常规按钮(EventName="Click")。我在 Pivot 之外也有相同的复制粘贴按钮。问题是枢轴外面的按钮工作正常,但里面的按钮不起作用。实际上我已经注意到,我的枢轴内的任何命令都不起作用。我正在正确处理 ViewModel 中的命令,因为相同的按钮,但在枢轴之外工作得很好。 任何想法可能是什么问题?请帮忙。 提前致谢。 干杯。
附:我的代码非常标准,但以防万一:
<controls:Pivot Grid.Row="0"
x:Name="PivotControl"
Title="{Binding ApplicationTitle}"
ItemsSource="{Binding BlaBla}">
<controls:Pivot.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Content="Click Me">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding MyCommand, Mode=OneWay}" CommandParameterValue="Test"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
...
以及 ViewModel 代码:
public RelayCommand<string> MyCommand
{
get;
private set;
}
//And in the constructor ...
MyCommand= new RelayCommand<string>((param) => HandleTheCommand(param));
...
再次感谢。
【问题讨论】:
标签: silverlight windows-phone-7 command pivot mvvm-light