我在调整WPF的Canvas
内部时遇到麻烦Grid
。我希望它在Right
和的Top
边有10px的空白Grid
。我在下面的代码中做错了什么?
<Window x:Class="Layout2.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 x:Name="DrawingArea" Background="Black">
<Canvas x:Name="InformationLayer"
Background="White"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Right="10"
Top="10"
Width="200" Height="30" >
</Canvas>
</Grid>
</Window>
Right
并且Top
是Canvas
在父Canvas
对象内放置元素的类的附加属性。我不认为它们在Canvas
标签本身中使用时具有语义(除非您嵌套在画布中)。
而是使用margin属性:
<Canvas x:Name="InformationLayer"
Background="White"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,10,10,0"
Width="200" Height="30" >
</Canvas>
边距格式设置为“左,上,右,下”,以防您需要修改!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句