Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:46:40+00:00 2026-05-31T15:46:40+00:00

I got a grid with 2 listviews in it. The listviews are the same(Only

  • 0

I got a grid with 2 listviews in it. The listviews are the same(Only itemsource is different for other items ofc) the datatemplate = Stackpanel that has 1 Label and an other grid. Now I want the grid (inside the stackpanel that is inside the Datatemplate) ONLY to be visible if the item is selected(The Label). I tried it with this code(that I put in the datatemplate of the Listview :

<StackPanel>
<Label content={binding blabla} />
<Grid Visibility="{Binding IsSelected,RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}, Mode=FindAncestor}, Mode=OneWay,  Converter={StaticResource BooleanToVisibilityConverter}}" >
...random labels etc...
</Gird>
</StackPanel>

This works! HOWEVER if I select an item in the 2nd listview (And only the 2nd) then the first one also shows that grid(on the same “item level”).(So for example on the 2nd listview I select the 3th item(the label), then the Grid is show on the 3th item of the 2nd listview but the 3th item grid is show on the first listview!!!!)

I Think this has to do with the relative source thing, but I coudn t find an answer.
Hope you guys can help me out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:46:42+00:00Added an answer on May 31, 2026 at 3:46 pm

    Just because a ListBox doesn’t have focus, doesn’t mean an item gets unselected, and I suspect you have the SelectedItem or SelectedIndex bound to the same property in both ListViews which is making the ListViewItem.IsSelected synchronized between the two ListViews

    I’d suggest making your Grid’s Visibility condition be based on 2 properties instead of 1: the ListViewItem.IsSelected is true, AND if the ListViewItem.IsKeyboardFocusWithin is set to True.

    Here’s an example using a DataTrigger

    <Style TargetType="{x:Type Grid}" x:Key="GridStyle">
        <Setter Property="Visibility" Value="Collapsed" />
        <Style.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Value="True" Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}" />
                    <Condition Value="True" Binding="{Binding Path=IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Visibility" Value="Visible" />
            </MultiDataTrigger>
        </Style.Triggers>
    </Style>
    

    Actually in retrospect, I think IsKeyboardFocusWithin will set the items as selected, so perhaps you only need to use IsKeyboardFocusWithin instead of IsSelected

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a grid that only displays one piece of information such as a
I got a combobox in the grid's column: <ListView> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate>
I've got a grid (dojox.grid v1.2) that I don't want to be sortable. How
I've got a single Silverlight app that I'd like to display in a grid.
I've got an RDL report that is a roster -- it's a grid: each
I've got a report that's supposed to take a grid control and produce HTML
I've got a DataGrid control that's within a Grid layout container, and I can't
I got Grid and Chart who shares same store. Also I got some checkboxes
I've got a grid that show tens of thousands of rows in total, obviously
I've got an UIScrollView with a grid of images. Currently they're only 6, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.