在阅读StackOverflow 上的这个答案后,我问了这个问题。
提供的答案非常适合让您移动整个控件。但是假设我有一个像这样创建的用户控件:
<UserControl x:Class="WpfTest.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Border Background="Blue">
<Grid>
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="26"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Canvas Grid.Row="0" Background="orange"></Canvas>
<Canvas Grid.Row="1" Background="Purple"></Canvas>
</Grid>
</Border>
</UserControl>
当我用鼠标单击控件的标题部分 Grid.Row[0] (橙色部分)时,我只希望控件移动。单击控件的其余部分时,我不希望控件响应拖动操作。
我怎样才能做到这一点?