binding window height and width and saving properties to file.

This commit is contained in:
Holger Börchers 2020-04-18 15:44:49 +02:00
parent a5d05e05a3
commit c44931c11e
2 changed files with 15 additions and 4 deletions

View File

@ -1,5 +1,4 @@
 <Window
<Window
x:Class="ModernWpfPlayground.MainWindow" x:Class="ModernWpfPlayground.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -11,8 +10,8 @@
xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:ui="http://schemas.modernwpf.com/2019"
x:Name="Window" x:Name="Window"
Title="{Binding Title}" Title="{Binding Title}"
Width="1200" Width="{Binding WindowWidth, Mode=TwoWay}"
Height="600" Height="{Binding WindowHeight, Mode=TwoWay}"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}" d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
prism:ViewModelLocator.AutoWireViewModel="True" prism:ViewModelLocator.AutoWireViewModel="True"
ui:ThemeManager.IsThemeAware="True" ui:ThemeManager.IsThemeAware="True"

View File

@ -93,6 +93,18 @@ namespace ModernWpfPlayground
set => SetProperty(value, SetTheme); set => SetProperty(value, SetTheme);
} }
public int WindowWidth
{
get => GetProperty(1200);
set => SetProperty(value);
}
public int WindowHeight
{
get => GetProperty(600);
set => SetProperty(value);
}
private static void SetTheme(ThemeMode themeMode) private static void SetTheme(ThemeMode themeMode)
{ {
ThemeManager.Current.ApplicationTheme = themeMode switch ThemeManager.Current.ApplicationTheme = themeMode switch