我目前正在为Windows Phone 8.0编写应用程序,我在MVVM Toolkit的灯光和弹出窗口中遇到了RelayCommand的问题。
我在弹出窗口中有一个LongListSelector:
<Popup x:Name="popUp" Grid.Row="0" Grid.RowSpan="3" Opened="PopupOpened">
<Grid>
<ScrollViewer Grid.Row="2" Margin="10">
<phone:LongListSelector ItemsSource="{Binding ItemsSelections}"
ItemTemplate="{StaticResource DetailsItemTemplate}" />
</ScrollViewer>
</Grid>
</Popup>
项目模板:
<DataTemplate x:Key="DetailsItemTemplate">
<Button VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="5,5,5,5"
Command="{Binding ElementName=LayoutRoot,Path=DataContext.ItemExecutionCommand}"
CommandParameter="{Binding Type}">
</Button>
</DataTemplate>
当我第一次打开弹出窗口时,一切正常,CanExecute返回false,禁用按钮并应用禁用样式(前景为灰色)。但是,当我关闭弹出窗口并再次打开时,按钮被禁用,但具有正常样式(前景为白色)。每次弹出窗口打开后执行RaiseCanExecuteChanged方法都无济于事。 有人有这个问题吗?