繁体   English   中英

具有NavigationCommands.Refresh的扩展WPF工具包DataGridControl

[英]Extended WPF Toolkit DataGridControl with NavigationCommands.Refresh

在我的WPF应用程序中,我希望将用户F5笔划作为刷新处理。 为了解决这个问题,我决定使用NavigationCommands.Refresh命令。

在UI内部,我利用Extended WPF Toolkit中DataGridControl 问题:只要焦点位于数据网格内,就不会触发刷新命令处理程序。

这可以通过一个非常小的示例来证明:

<Window x:Class="WpfTests.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xd="http://schemas.xceed.com/wpf/xaml/datagrid">
    <Window.CommandBindings>
        <CommandBinding Command="NavigationCommands.Refresh" Executed="CommandBinding_Executed" CanExecute="CommandBinding_CanExecute"/>
    </Window.CommandBindings>
    <StackPanel>
        <TextBox Text="Click me to get the focus out of DataGridControl"/>
        <xd:DataGridControl/>
    </StackPanel>
</Window>

后面的代码没什么好想的,我只是用它在处理程序中放置断点:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

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

    private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
    {
        e.CanExecute = true;
        e.Handled = true;
    }
}

复制:

  • 启动应用程序,按F5键-执行处理程序
  • 单击进入DataGridControl区域,按F5键-未执行处理程序
  • 单击进入文本框,按F5键-执行处理程序

所以问题是,当焦点位于DataGridControl内时,当用户按F5键时,如何确保执行刷新处理程序?

好的,我终于偶然发现了解决方案。

https://xceed.com/forums/topic/what-is-the-function-key-F5-in-datagrid-for/

DataGridControl.IsRefreshCommandEnabled属性设置为False阻止datagridcontrol将F5键用于其内部逻辑。 然后按预期方式调用该处理程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM