ListViewItem工具提示WPF [英] ListViewItem tooltip WPF

查看:118
本文介绍了ListViewItem工具提示WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是,当鼠标单击每个列表视图时,会在工具提示中向我显示每个视图的所有数据.

What I need is that when mouse per listviewitem show me all data from each in a tooltip.

这是我的观点的一部分

...
...
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
...
...

private ObservableCollection<Articulo> _articulos;

private Articulo _articuloSeleccionado;

        public ObservableCollection<Articulo> Articulos
        {
            get { return _articulos; }
            set
            {
                _articulos = value; 
                RaisePropertyChanged();
            }
        }

        public Articulo ArticuloSeleccionado
        {
            get { return _articuloSeleccionado; }
            set
            {
                _articuloSeleccionado = value;
                RaisePropertyChanged();
            }
        }

我的.xalm

            <ListView Name="lvResultado"
                      ItemsSource="{Binding Articulos}"
                      SelectedItem="{Binding ArticuloSeleccionado}">
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Código de barras" Width="200" DisplayMemberBinding="{Binding CodigoDeBarras}"/>
                        <GridViewColumn Header="Descripción" Width="250" DisplayMemberBinding="{Binding Descripcion}"/>
                    </GridView>
                </ListView.View>
            </ListView>

感谢您的帮助.我尝试了几件事,但没有好结果.

Thank you for your help. I tried several things but no good result.

推荐答案

您可以定义用于设置工具提示模板和内容的ItemContainerStyle.

You can define an ItemContainerStyle that would set your tooltip template and content.

请参见下面的示例,在这里我定义了UniformGrid以在一列中显示多行文本.您可以根据需要随意设置工具提示.您仍然需要告诉视图哪些数据属性需要显示在工具提示中.

See an example below, here I define an UniformGrid to display multiple text lines in one column. You are free to setup your tooltip as you wish. You still need to tell the view which data properties need to be displayed in the tooltip.

<ListView ItemsSource="{Binding Articulos}">
  <ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
      <Setter Property="ToolTip">
        <Setter.Value>
          <UniformGrid Columns="1">
            <TextBlock Text="{Binding CodigoDeBarras}"/>
            <TextBlock Text="{Binding Descripcion}"/>
            <TextBlock Text="{Binding AnyOtherProperty}"/>
          </UniformGrid>
        </Setter.Value>
      </Setter>
    </Style>
  </ListView.ItemContainerStyle>
</ListView>

这篇关于ListViewItem工具提示WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆