Cannot Apply Location and WindowSize from Config
<p>I want some properties of my <code>Window</code> saved to xml on termination and be reloaded and applied on startup.</p>

<p>I am saving the values to <code>XML</code> which is working fine so far.
I update the values in my ViewModel in the relating <code>ChangedEvents</code>.</p>

<pre><code>[Serializable]
public class UserSettings
{
    public double WindowWidth { get; set; }

    public double WindowHeight { get; set; }

    //GridSplitter
    public double GridLength_Pixels { get; set; }

    public double WindowPositionX { get; set; }
    public double WindowPositionY { get; set; }
}
</code></pre>

<p>This is my <code>XAML</code>:</p>

<pre><code>&lt;Window x:Class="MonitorTool.Windows.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:MonitorTool"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"         
    Title="Transport Monitor" 
    MinWidth="300"
    MinHeight="550"
    Height="{Binding WindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
    Width="{Binding WindowWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"         
    Topmost="{Binding ElementName=TopMostCheckBox, Path=IsChecked}"
    Icon="{Binding Path=Icon, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
    Left="{Binding Path=LocationX, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
    Top="{Binding Path=LocationY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"&gt; 
[...]
</code></pre>

<p>The propertiesin my ViewModel are all quite the same so i'll just pose one here but it should be clear:</p>

<pre><code> public double WindowWidth
    {
        get { return _windowWidth; }
        set
        {
            _windowWidth = value;
            OnPropertyChanged("WindowWidth");
        }
    }
</code></pre>

<p>So I've created a Method called <code>ApplyUserSettings</code> which is called in <code>MainWindow_ContentRendered</code> where I load my Config and fill the properties with these values.</p>

<p>But nothing is happening and I got no idea where to look for a solution.
I've found alot of examples online where ppl store to defaultSettings but that doesn't seem like a big difference - so it should work the same with my own settings file.</p>

<p>Anyone an idea what could be wrong here ?</p>

<p><strong>EDIT:</strong></p>

<p>It seems like the Window startups with <code>MinWidth</code> and <code>MinHeight</code>.</p>

<p><strong>EDIT V2: The ViewModel:</strong></p>

<p>In <code>MainWindow.xaml.cs</code>:</p>

<pre><code>public MainWindow()
    {
        InitializeComponent();
        if(MainWindowViewmodel.Instance == null)
        {
            MainWindowViewmodel.Instance = new MainWindowViewmodel(this);
        }            
        DataContext = MainWindowViewmodel.Instance;
        InitializeTray();
        TrayIcon.Visible = true;
    }  
</code></pre>

<p>As you can see the value is set correctly but it seems like its not applied ;(
<a href="https://i.stack.imgur.com/iTdKe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iTdKe.png" alt="enter image description here"></a></p>