How do the RoutedCommand constructors differ from eachother?
The RoutedCommand in WPF has 3 overloaded constructors.
Consider the following:
public static RoutedCommand AddTextFieldCommand = new RoutedCommand();
vs
public static RoutedCommand AddTextFieldCommand = new RoutedCommand("AddTextField", typeof(DesignerWindow));
What advantage does the second one have?
Does it make it easier to define in XAML ? MSDN doesn't really give much details about the secon开发者_JS百科d constructor.
From my experience, there's no real semantic difference between the two. For me, they both seem to function exactly the same. I won't say definitively that there isn't a difference, I just haven't noticed one.
However, what I have noticed is that at least using the constructor that allows you to add a name, and adding a useful name, can really help with debugging. At a break point where you're handling routed commands you can much more easily tell which command it is if all of your commands have names.
-- HTH, Dusty
精彩评论