开发者

How do the RoutedCommand constructors differ from eachother?

开发者 https://www.devze.com 2022-12-12 16:34 出处:网络
The RoutedCommand in WPF has 3 overloaded constructors. Consider the following: public static RoutedCommand AddTextFieldCommand = new RoutedCommand();

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

0

精彩评论

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