在我的 WPF 项目中,我有一个Canvas
画图。按照窗口的代码:
<Window x:Name="PropertyDefinition_Window" x:Class="PushOverStraus7.PropertyDefinitionWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PropertyDefinitionWindow" Height="360" Width="730" Loaded="Window_Loaded">
<Grid>
<TreeView SelectedItemChanged="Treeview_PropertyDefinition_SelectedItemChanged">
<TreeViewItem IsExpanded="True">
<TreeViewItem />
</TreeViewItem>
<TreeViewItem>
<TreeViewItem"/>
</TreeViewItem>
</TreeView>
<Canvas x:Name="Canvas_LongitudinalBarRectanglePage" HorizontalAlignment="Left" Height="251" Margin="255,10,0,0" VerticalAlignment="Top" Width="285" Background="Black">
</Canvas>
<Button x:Name="NewButton" Content="Nuovo" HorizontalAlignment="Left" Margin="22,277,0,0" VerticalAlignment="Top" Width="45" Click="NewButton_Click"/>
<Button x:Name="DuplicateButton" Content="Duplica" HorizontalAlignment="Left" Margin="85,277,0,0" VerticalAlignment="Top" Width="45"/>
</Grid>
我想要那个,调整窗口的大小,Canvas
大小会相应地改变。ActualWidth
然后,我需要ActualHeight
调整 Canvas 的大小以使用它们来绘制算法。如何自动调整 Canvas 的大小以及如何获取上述值?谢谢你的帮助
编辑:我已按要求更改了问题