routed-commands

Do I have to use CommandTarget? I thought any focused element would receive the Command

随声附和 提交于 2019-11-27 18:48:05
问题 I'm trying to understand how to use RoutedCommands. I was under the impression that if I don't specify a CommandTarget on the Button, any focused element will receive the command. But for some reason it doesn't work. Here is the xaml that doesn't work: <Window x:Class="WpfTest11_Commands2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBox Height="177"

WPF Commands, How to declare Application level commands?

随声附和 提交于 2019-11-27 13:47:46
问题 I'm interested in creating commands that are available from anywhere in my WPF application. I'd like them to work in the same way as Cut , Copy , Paste and the other Application level commands, ie: <Button Command="Paste" /> I assumed I could setup CommandBindings for the Application instance, but that property isn't available. How is this done? The best I have managed so far is to create a suite of commands on the top level window and then access them like this...: <Button Command="{x:Static

How to bind ApplicationCommands to a ViewModel?

喜你入骨 提交于 2019-11-27 01:55:23
问题 I have successfully used a few custom commands using MVVM-Light, but I want my application to respond to the standard ApplicationCommands, not just at a Window level, but at a detailed item level as well. I have a TreeView that I want to be able to copy and paste nodes in. Each TreeViewItem has its own ViewModel, and they are displayed via HierarchicalDataTemplates in XAML as there are several different types. I have implemented methods to copy, paste, as well as CanCopy and CanPaste on my