Update: This issue might be related to Problems with binding to Window Height and Width
I'm trying to change the window height through the view model property. For some reason, it does not work.
This is the window class:
public partial class MyWindow
{
public MyWindow()
{
InitializeComponent();
DataContext = new MyWindowViewModel();
// Does not work!
// ((MainWindowViewModel) DataContext).Height = 50;
// Works:
//Height = 50;
MyWindow.xaml
<ctrls:MyBaseWindow x:Class="....MyWindow"
...
Width="{Binding Width}"
Height="{Binding Height}"
d:DataContext="{d:DesignInstance viewModels:MyWindowViewModel}">
MyWindowViewModel.cs
public class MainWindowViewModel : ReactiveObject
{
...
public int Height
{
get { return _height; }
set { this.RaiseAndSetIfChanged(ref _height, value); }
}