11智能在线
新记
WPF下如何让控件大小跟着窗口的大小变化而变化
如题所述
举报该文章
相关建议 推荐于2016-02-28
<Window x:Name="window" x:Class="WpfApplication1.MainWindow"
xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation
"
xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml
"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Rectangle x:Name="rectangle" Fill="#FF53A8F1" Width="{Binding ActualWidth, ElementName=window, Mode=OneWay}"
Height="{Binding ActualHeight, ElementName=rectangle, Mode=OneWay}" />
</Grid>
</Window>
思路就是,用控件的高度宽度和窗体的相关属性做绑定。当然还可以用Converter做进一步的设置。
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/7qmp72sp7fv8qvq84p.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
C# wpf 想让控件随着窗口大小变化而变化
C#中怎么使控件随着窗体的大小改变而改变
WPF的窗口中的所有内容随窗口大小变化而同步变化
winform 如何使控件随着窗体的大小改变而改变?
C#控件的位置和大小随窗体大小的变化而变化
如何实现控件随对话框大小变化而自动调整大小和位置
mfc 窗口大小变化时,如何让窗口内部控件也一起随比例改变位...
怎样让DataGridView的大小,随窗口的大小变化而变化