rap*_*011 1 wpf drag-and-drop canvas border rounded-corners
我有这个代码:
<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>
Run Code Online (Sandbox Code Playgroud)
我希望画布具有圆角,直到我将文本块拖动到任一侧之前,它都可以工作。然后角落消失了。这是我程序中窗口的简单重现,我在那里使用拖放操作来移动文本块。我确实需要那些圆角,但是我绝对不知道如何解决这个问题!
有任何想法吗??
编辑:当文本块移动到边缘时,似乎画布被拉伸了(因为拐角半径也改变了!)
只是想到了另一种解决方案。
<Border ClipToBounds="True" CornerRadius="6" Background="White" Name="brdEtikett" Height="200" Width="200" >
<Canvas Name="cnvsEtikett" Background="Transparent" />
</Border>
Run Code Online (Sandbox Code Playgroud)
将边框的背景设置为您想要在画布上使用的颜色,并使画布透明!
这样,您不必在元素上添加填充或边距!
| 归档时间: |
|
| 查看次数: |
4305 次 |
| 最近记录: |