Cant assign SHIFT+Delete KeyGesture to DevExpress bar item in WPF. Is there any restriction on that or am i doing it wrongly?
<dxb:BarButtonItem
x:Name="btnDelete"
Command="{Binding BtnDelete_Command}"
开发者_开发技巧CommandParameter="{Binding ElementName=view}"
KeyGesture="SHIFT+Delete"
Content="Delete" /> Here is the code I tried:
<dxb:BarManager>
<dxb:BarManager.Items>
<dxb:BarButtonItem x:Name="btnDelete" Command="{Binding BtnDelete_Command}" CommandParameter="{Binding ElementName=view}" KeyGesture="SHIFT+Delete" Content="Delete" />
</dxb:BarManager.Items>
<dxb:BarManager.Bars>
<dxb:Bar>
<dxb:Bar.ItemLinks>
<dxb:BarButtonItemLink BarItemName="btnDelete"/>
</dxb:Bar.ItemLinks>
</dxb:Bar>
</dxb:BarManager.Bars>
<StackPanel>
<Button Content="sdgsdg" />
<TextBox x:Name="view"/>
</StackPanel>
</dxb:BarManager>
public partial class MainWindow : Window {
public ICommand BtnDelete_Command { get; set; }
public MainWindow() {
BtnDelete_Command = new MyCommand();
DataContext = this;
InitializeComponent();
}
}
public class MyCommand : ICommand {
public bool CanExecute(object parameter) {
return true;
}
public event EventHandler CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter) {
MessageBox.Show(parameter.GetType().ToString());
}
}
It works properly here. If the editor is not focused, the command is executed. If the editor is focused, it processed this key combination itself and thus command isn't executed.
加载中,请稍侯......
精彩评论