WPF binding default value

I linked the Height and Width my window. Now in Visual Studio, the window is so small that I can no longer work on it. Setting the default values ​​to Height and Width will solve my problem. Is this possible in Binding ?

 <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> 

Can we set default values ​​in WPF Binding ? How?

+5
data-binding default-value wpf
source share
1 answer

See FallbackValue :

 <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, FallbackValue=200}" Height="{Binding Path=HeightOfImage, Mode=TwoWay, FallbackValue=150}" > ... </Window> 

You can also use MinWidth or MinHeight to solve the small window problem.

+10
source share

All Articles