如何「停靠」其父項中的畫布?將畫布停放在其父項中
我有一個UserControl,其中包含一個畫布。
<UserControl x:Class="MyUC"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<MyCanvas x:Name="myCanvas"
Height="???"
Width="???{Binding RelativeSource={RelativeSource TemplatedParent}}" >
</MyCanvas>
</UserControl>
我用這裏面的自定義帆布Width
和Height
性能。並且需要該屬性始終「綁定」到父容器。
這樣,您的UserControl始終與上面的容器大小相同?你可以粘貼更多的xaml嗎? – user109134 2010-10-27 09:59:25
@ user109134:UserControl也應該停靠在其父 - 表單上。所以它的尺寸是可變的 – serhio 2010-10-27 10:03:49