WPF绑定中的默认值

编程入门 行业动态 更新时间:2024-10-22 13:35:22
本文介绍了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绑定中的默认值

本文发布于:2023-11-07 06:23:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   默认值   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!