tags:

views:

86

answers:

2

B"H

I would like to control the height and width of one of my windows through my ViewModel.

This seems simple enough.

<Window ... Width="{Binding Path=Width}" Height="{Binding Path=Height}" />

but nope. it doesn't work.

It checks the ViewModel's Width but not the Height.

Strangely enough, if I switch the order of Width and Height in the XAML it checks the Height and not the Width. i.e. It only checks the first of the two properties and totally ignores the second one.

Binding the MaxHeight and MinHeight do work, even after the Width. But then the user can not re-size the window.

A: 

I'm having this exact problem also, it seems like a bug.

For now I am just handling the DataContextChanged event of the Window and setting the Width and Height from the ViewModel manually.

Shawn
A: 

Don't know what your ViewModel code looks like, but try creating a set for the Width and Height properties and set the binding Mode to TwoWay

Ruleland