I am trying to set the MinHeight / MinWidth of a resizeable window based on its initial height (when SizeToContent="WidthAndHeight").
I have seen a couple of answers / solutions:
http://weblogs.asp.net/psheriff/archive/2010/01.aspx
Set form MinWidth and MinHeight based on child property
However:
I am trying to use the MVVM pattern and would like to be able to achieve this in the xaml.
I would also like to keep values such as MinHeight out of the ViewModel - I dont think they belong there as they tie a trivial part of the behaviour of the view to the viewmodel. This is something I would like to leave to the UX designer.
A solution I am struggling with is to use the following xaml / binding:
<Window
....
x:Name="mainWindow"
SizeToContent="WidthAndHeight"
ResizeMode="CanResizeWithGrip"
MinHeight="{Binding ElementName=mainWindow, Mode=OneTime, Path=ActualHeight}"
>
I would hope that 'Mode=OneTime' would bind the MinHeight to the initial value of the windows height.
But it does not work..
Can someone please explain why? Is there a solution that meets my criteria?
Thanks,
Mark