【发布时间】:2011-10-22 11:11:55
【问题描述】:
我有这个代码:
<Window x:Class="WpfApplication8.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>
<ScrollViewer Background="#FFADB9CD" >
<Grid>
<Border Name="mask" Height="{Binding ElementName=cnvsEtikett, Path=Height}" Width="{Binding ElementName=cnvsEtikett, Path=Width}" Background="White" CornerRadius="6"/>
<Canvas Height="100" Name="cnvsEtikett" Width="200" Background="White" ClipToBounds="True">
<Canvas.OpacityMask>
<VisualBrush Visual="{Binding ElementName=mask}" />
</Canvas.OpacityMask>
<TextBlock Height="23.2" Text="TextBlock" Canvas.Left="63" Canvas.Top="41" />
</Canvas>
</Grid>
</ScrollViewer>
</Grid>
</Window>
我希望画布具有圆角,直到我将文本块拖动到任一侧为止。然后角落消失。这是我程序中窗口的简单重新创建,在那里我使用拖放操作来移动文本块。我真的需要那些圆角,但我完全不知道如何解决这个问题!
有什么想法吗??
编辑:当文本块移动到边缘时,画布似乎被拉伸了(因为角半径也发生了变化!)
【问题讨论】:
-
这只是一个范围,所以我什至不打算将其发布为答案。也许尝试给 TextBlock 一个边距。边距可能是透明的,并且会阻止不透明的内容到达边界。但由于半径发生变化,我认为这不会奏效。但是很容易尝试。或者我会尝试将高度和宽度放在网格列和行上,然后将边框放在具有拉伸高度和宽度的行列中。再次,只是要尝试的事情。
标签: wpf canvas drag-and-drop border rounded-corners