我创建了以下名为“InertListView”的 wpf 控件,它是一个自定义 ListView:
<Plugins:InertListView ItemsSource="{Binding Path=Data.InputPorts}"
Grid.Column="0"
Background="Transparent"
BorderThickness="0"
BorderBrush="{x:Null}"
>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Path Name="LeftPort"
Fill="{Binding Color}"
go:Node.PortId="{Binding Type}"
Tag="Left"
go:Node.LinkableFrom="False"
go:Node.LinkableTo="True"
go:Node.ToSpot="MiddleLeft"
go:Node.LinkableMaximum="1"
Grid.Column="0"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Cursor="Hand"
Width="10.968"
Height="14"
Stretch="Fill"
StrokeThickness="2"
StrokeMiterLimit="2.75"
Stroke="#FF535755"
Data="F1 M 16.9835,22.9609C 16.7301,23.2861 16.1852,23.5528 15.7721,23.5528L 12.7187,23.553C 12.3071,23.553 11.9687,23.2161 11.9687,22.803L 11.9687,12.3032C 11.9687,11.8901 12.3071,11.5532 12.7187,11.5532L 15.7721,11.553C 16.1852,11.553 16.7301,11.8196 16.9835,12.1447L 20.7466,16.961C 21,17.2862 21,17.8195 20.7466,18.1447L 16.9835,22.9609 Z "
/>
<TextBlock x:Name="LabelPortLabel"
TextAlignment="Left"
FontFamily="/Connect IO;component/Fonts/#Segoe UI"
Grid.Column="1"
VerticalAlignment="Center"
FontSize="13"
Width="Auto"
Height="Auto"
Canvas.Top="0"
Text="{Binding Label}"
Margin="5 0 0 0"
Cursor="Arrow"
/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</Plugins:InertListView>
下面我展示了我如何定义“InertListView”:
public class InertListView : ListView
{
protected override DependencyObject GetContainerForItemOverride()
{
return new InertListViewItem();
}
}
public class InertListViewItem : ListViewItem
{
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
//base.OnMouseLeftButtonDown(e);
//e.Handled = false;
}
}
我的问题是,当我将鼠标移到其中一个 ListViewItems 上时,会出现一个突出显示的蓝色矩形。我怎样才能避免这种行为?
提前致谢!
里卡多