none
Problemas em recuperar as colunas de um listView--WPF RRS feed

  • Pergunta

  • oi, populei o listView, e fiz um binding com as colunas, segue o codigo....

     

     

    <ListView HorizontalAlignment="Left" Margin="21.671,133,0,276.722" x:Name="listEventosOrigem" Width="306.728" SelectionChanged="listEventosOrigem_SelectionChanged" SelectedValuePath="Cliente">

    <ListView.View>

    <GridView>

    <GridViewColumn Header="Cliente" Width="45" DisplayMemberBinding="{Binding Path=Cliente}" />

    <GridViewColumn Header="Hora" Width="57" DisplayMemberBinding="{Binding Path=Hora}" />

    <GridViewColumn Header="Evento" Width="50" DisplayMemberBinding="{Binding Path=Evento}" />

    <GridViewColumn Header="Prioridade" Width="56" DisplayMemberBinding="{Binding Path=Prioridade}" />

    <GridViewColumn Header="Ultima A‡Æo" Width="120" DisplayMemberBinding="{Binding Path=Ultima}" />

    </GridView>

    </ListView.View>

    </ListView>

     

    o problema é o seguinte, quando seleciono uma linha do list, gostaria de ter acesso a mais de um valor dessa linha, e não estou conseguindo, já usei quase todas a propriedade e consigo apenas pegar uma coluna dessa linha selecionada....

    Me ajudem por favor Sad

     

    quarta-feira, 20 de agosto de 2008 20:53

Respostas

  • Big Smile achei...

     

    WPF ListView - Getting the Clicked Item

    I recently had the need to figure out which item in a WPF ListView was under the mouse when it was clicked. The solution wasn't completely straightforward, so I thought I'd post it here.

    First, obviously you need to register a mouse button event hander in your control initialization. In this case, I'm using a double-click event:
    MyListView.MouseDoubleClick += new MouseButtonEventHandler(MyListView_MouseDoubleClick);
    and then implement the event handler like such:
    void MyListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
    DependencyObject dep = (DependencyObject)e.OriginalSource;

    while ((dep != null) && !(dep is ListViewItem))
    {
    dep = VisualTreeHelper.GetParent(dep);
    }

    if (dep == null)
    return;

    MyDataItemType item = (MyDataItemType)MyListView.ItemContainerGenerator.ItemFromContainer(dep);

    // Do something with the item...
    }

    http://mikescodeblog.blogspot.com/2007/12/wpf-listview-getting-clicked-item.html

     

    quinta-feira, 21 de agosto de 2008 16:42