2010-02-10 10 views
5

Ho legato il Height e Width della mia finestra. Ora, la finestra è così piccola in Visual Studio che non posso più lavorarci su. L'impostazione dei valori predefiniti su Height e Width risolverebbe il mio problema. È possibile in Binding?Valore predefinito in Rilegatura WPF

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

possiamo impostare i valori predefiniti in WPF Binding? Come?

risposta

9

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

Si potrebbe anche essere in grado di utilizzare MinWidth o MinHeight per affrontare il problema piccola finestra.