开发者

How to request in WPF app if tabs can close

In an application that has a tab control with multiple tabs where each one contains an entity which is possibly being edited, how would you signal the tabs to find out if they are in edit mode and sh开发者_StackOverflowouldn't close?

RoutedCommand or RoutedEvent maybe?

So the top window needs to request all children that are open (they may be of different types etc) whether they can close.


RoutedCommand. It's what they're for!

If all the children are different types then having an IClosable interface (with CanClose and Close()) for each of the classes means you can iterate over the collection without knowing anything about the different types.


RoutedEvent, event has to propogate to through all children in two phases, first should be

Closing Routed Event with cancellable variable to either cancel the whole close operation and after complete propogation of Closing event, you should propogate Close event.

If you want to send some sort of notification to any other object, you should use RoutedEvent, closing/close are notifications (events) to be handled by the object being closed.

If you want to invoke a method of an object (command) then you should use RoutedCommand.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜