2010-02-10 10 views
5

Adjunté Height y Width de mi ventana. Ahora, la ventana es tan pequeña en Visual Studio que ya no puedo trabajar en ella. Establecer los valores predeterminados a Height y Width resolvería mi problema. ¿Es posible en Binding?Valor predeterminado en WPF Enlace

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

Podemos establecer los valores por defecto en WPF Binding? ¿Cómo?

Respuesta

9

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

También podría ser capaz de utilizar MinWidthMinHeight o para hacer frente a su problema de la ventana pequeña.