views:

43

answers:

1

Can we set default values in WPF DataBinding?

e.g : I've bound the Height and Width of my window to some properties as follows.

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    x:Class="Sth.MainWindow"
    x:Name="Window"
    Width="{Binding Path=WidthOfImage, Mode=TwoWay}" 
    Height="{Binding Path=HeightOfImage, Mode=TwoWay}" >
    ...
</Window>

With above XAML code, we have a tiny window in Visual Studio, and we can't work on the window anymore!
Now I wanna set some default values to Height and Width for solving the problem.
Is it possible in DataBinding? If so, would you please post the solution?
Any help would be appreciate.

+2  A: 

See FallBackValue

you might also be able to use MinWidth or MinHeight to address your small window issue

qntmfred