Question

I created the following wpf control called "InertListView" that it is a custom 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>

Below i show how i define the "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;
    }
}

My problem is that when i move the mouse over one of the ListViewItems appears a highlight blue rectangle. How can i avoid this behaviour?

Thanks in advance!

Ricardo

Was it helpful?

Solution

You'd need to change the template of the control. Something like this:

<Plugins:InertListView>
    ......
    ......
    <Plugins:InertListView.ItemContainerStyle>
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListViewItem}">
                        <Border x:Name="Bd"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Plugins:InertListView.ItemContainerStyle>
</Plugins:InertListView>

OTHER TIPS

Override the HighlightBrush like below:

<Plugins:InertListView    ItemsSource="{Binding Path=Data.InputPorts}"
                          Grid.Column="0" 
                          Background="Transparent"
                          BorderThickness="0"
                          BorderBrush="{x:Null}"
                          >
<Plugins:InertListView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                             Color="Transparent"/>
</Plugins:InertListView.Resources>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top