在WPF数据绑定默认值吗? [英] Default values in WPF DataBinding?
问题描述
我们能在WPF数据绑定设置默认值?
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>
通过上面的XAML code,我们在Visual Studio中一个很小的窗口,我们不能在窗口上工作了!
现在,我想解决问题的方法设置一些默认值,高度和宽度。
是否有可能在数据绑定?如果是这样,请你张贴的解决方案吗?
任何帮助将是AP preciate。
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.
推荐答案
请参阅<一href="http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.fallbackvalue.aspx">FallBackValue
您也许还能够使用或了minWidth到了minHeight解决您的小窗口的问题
you might also be able to use MinWidth or MinHeight to address your small window issue
这篇关于在WPF数据绑定默认值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!