I'm creating a WPF application with a borderless window. Applying the MVVVM
pattern (with help of Caliburn.Micro) I do not have a code behind file but only a XAML file.
In several posts I found following solution:
XAML:
<Window
...
WindowStyle="None" MouseLeftButtonDown="WindowMouseLeftButtonDown"/>
Code behind:
private void WindowMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
Now I'm searching a solution to define this completely in XAML.
Any idea?
You can download the Microsoft.Windows.Shell dll (Link. You can find another download options with google), which gives you a property of CaptionHeight that enables tou to drag the window from its top part (like a normal window).
I know that I am a little late to the question, but this is what I have been using for sometime now and it works like a charm.
and something like this in your viewModel
Using the ICommand interface...
Configure the commands...
Here is the RelayCommand class.
And some example methods...
Hope this helps!
You can use an
EventCommandTrigger
. Check these references:http://www.danharman.net/2011/08/05/binding-wpf-events-to-mvvm-viewmodel-commands/ http://zamjad.wordpress.com/2011/06/07/convert-event-into-command-in-mvvm-model/
The solution I will present is not really advised, but you can put your code behind right in your XAML file like this:
Check this Codeproject article for more information on this!
I think your best option is a behavior.
http://wpftutorial.net/Behaviors.html