本文介绍了WPF绑定中的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经绑定了我的窗口的 Height 和 Width 。现在,Visual Studio中的窗口很小,我不能再工作了。将默认值设置为高度和宽度可以解决我的问题。是否可以在绑定?
I've bound the Height and Width of my window. Now, the window is so tiny in Visual Studio I can't work on it anymore. Setting default values to Height and Width would solve my problem. Is it possible in Binding?
<Window xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" xmlns:d="schemas.microsoft/expression/blend/2008" xmlns:mc="schemas.openxmlformats/markup-compatibility/2006" x:Class="Sth.MainWindow" x:Name="Window" Width="{Binding Path=WidthOfImage, Mode=TwoWay}" Height="{Binding Path=HeightOfImage, Mode=TwoWay}" > ... </Window>我们可以在WPF中设置默认值绑定 ?如何?
Can we set default values in WPF Binding? How?
推荐答案请参阅 FallbackValue :
<Window xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" xmlns:d="schemas.microsoft/expression/blend/2008" xmlns:mc="schemas.openxmlformats/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>您也可以使用 MinWidth 或 MinHeight 解决您的小窗口问题。
You might also be able to use MinWidth or MinHeight to address your small window issue.
更多推荐
WPF绑定中的默认值
发布评论