开发者

Strange Behavior Between ListCollectionView.Refresh() and RoutedCommand

I have a ListView which is bound to a ListCollectionView.

In the same window I have a Button with an attached RoutedCommand with no CanExecute handler.

    public static RoutedCommand RefreshCommand = new RoutedCommand();

<CommandBinding Command="{x:Static local:DatabaseTaskViewer.RefreshCommand}"Executed="RefreshCommandExecute开发者_开发知识库d"/>

<Button Command="{x:Static local:DatabaseTaskViewer.RefreshCommand}">Refresh</Button>



private void RefreshCommandExecuted(object sender, ExecutedRoutedEventArgs e)
{
    Presenter.Process();
    e.Handled = true;
}

The problem is that whenever I do a ListCollectionView.Refresh() to apply a new filter to my collection, the Button gets disabled... until I click on a row in my ListView!

I isolated the problem between the Refresh() and the RoutedCommand (if I exclude the command from the Button it stays enabled).

Have you heard something similar before? Do you have any idea what to do?

Thank you in advance.


I would suggest to check your RefreshCommandExecuted, you somehow affect Command's Enable state. Regards.


Try setting command target to its parent.
Ref: http://msdn.microsoft.com/en-us/magazine/cc785480.aspx


I give up... I will go for the RelayCommand solution...

Thanks everyone who tried to help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜