Event bindings

Docking/MDI for WPF Forum

Posted 3 years ago by Michael Bayer
Version: 16.1.0633
Avatar

Hi,

with ribbon buttons I'm able to bind the Click event to a command like as follows:

<ribbon:Button Label="DoAnything" Command="{Binding DoAnythingCommand}"/>

I guess, this works, because the Click event is the default event of the button.

Is there an equivalent approach to bind events like DockSite.WindowsClosed using MVVM?

Thanks

Michael

[Modified 3 years ago]

Comments (1)

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

In general, buttons fire their Command when clicked and also raise a Click event, but other than them both executing when a click occurs, they aren't related.  DockSite's WindowClosed event is a normal event and can be handled the same as any other .NET event. 

This site has a good tutorial on attaching to event handlers from XAML:

http://www.wpf-tutorial.com/xaml/events-in-xaml/

There isn't a command available for when windows are closed though.  Your view would have to handle the event and then in its handler, call whatever it needs to on your view model.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.