Formular una preguntaFormular una pregunta
 

RespondidaDisable ListView selection and hover cues

  • sábado, 07 de noviembre de 2009 0:25Jimbo Mx Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I'm developing a ListView with a GridView in it. I am coloring each ListViewItem based on a magnitude figure. All is well until I mouse over the ListView or select an item, when the color is changed based on the standard behavior of a ListView.

    What would be the simplest/best way to disable the default row highlighting on mouse hover and selection?

    --- Jim ---

Respuestas

  • sábado, 07 de noviembre de 2009 19:38Stephanne Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     RespondidaTiene código

    Jimbo,

    You should try somthing like:

    <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <Border Background="{Binding Path=MyColor}">
                                <GridViewRowPresenter />   
                            </Border>                         
                        </ControlTemplate>
    
    MyColor, in my case is a SolidColorBrush property of my underlying data object. It should work in your case also with the converter applied to your needs...
    • Marcado como respuestaJimbo Mx sábado, 07 de noviembre de 2009 19:42
    •  

Todas las respuestas

  • sábado, 07 de noviembre de 2009 19:08Stephanne Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código
    Hi Jimbo,

    You need to reset the control template for the listviewitem.
    This should work fine:

    <Style TargetType="{x:Type ListViewItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <GridViewRowPresenter />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    
    Hope this helps.
  • sábado, 07 de noviembre de 2009 19:25Jimbo Mx Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código

    Thanks for the response Stephanne, however with this I run into a problem in that my background setter on the style no longer works. Do I need to hook up the background setter/converter somewhere within the template?

        <Style TargetType="{x:Type ListViewItem}">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListViewItem}">
                <GridViewRowPresenter />
              </ControlTemplate>
            </Setter.Value>
          </Setter>
          <Setter Property="Background">
            <Setter.Value>
              <Binding Path="MyField" Converter="{StaticResource MyConverter}" />
            </Setter.Value>
          </Setter>
        </Style>
    
    
  • sábado, 07 de noviembre de 2009 19:38Stephanne Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     RespondidaTiene código

    Jimbo,

    You should try somthing like:

    <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <Border Background="{Binding Path=MyColor}">
                                <GridViewRowPresenter />   
                            </Border>                         
                        </ControlTemplate>
    
    MyColor, in my case is a SolidColorBrush property of my underlying data object. It should work in your case also with the converter applied to your needs...
    • Marcado como respuestaJimbo Mx sábado, 07 de noviembre de 2009 19:42
    •  
  • sábado, 07 de noviembre de 2009 19:43Jimbo Mx Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    That did the trick! Thanks for saving me literally hours with my wheels spinning in the sand.

    --- Jim ---