I have a xaml window and on the StateChanged event of the window I have to execute a piece of code. I have to follow MVVM. I binded the StateChanged property to an ICommand? It doesn't work.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DummyApp"
x:Name="Window"
Title="Dummy App"
Width="{Binding WindowWidth,Mode=OneWayToSource}" Height="{Binding WindowHeight}" ResizeMode="CanMinimize" Icon="Logo.png" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" WindowState="{Binding CurrentWindowState, Mode=TwoWay}"
ShowInTaskbar="{Binding ShowInTaskBar, Mode=TwoWay}" StateChanged="{Binding IsMinimized}">
This is my viewmodel.
public ICommand IsMinimized
{
get
{
if (_IsMinimized == null)
{
_IsMinimized = new RelayCommand(param => this.OnMinimized(), null);
}
return _IsMinimized;
}
}
private void OnMinimized()
{
//do something here
}
Is there anyother way to do this?