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 8316461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:22:09+00:00 2026-06-08T21:22:09+00:00

I have a view in XAML where I have a listbox, and a selection

  • 0

I have a view in XAML where I have a listbox, and a selection in that listbox populates an area to the side with properties from the selected instance of the ChildViewModel. I have a few buttons in the ChildView that are connected to commands in the ChildViewModel. Before I make a selection from the parent listbox, these buttons do nothing as expected. How could I keep these buttons hidden until a selection selection in the parent listbox is made, thus creating an instance of the ChildViewModel.

I know how I could accomplish this if these buttons were part of the parent view by binding the visibility of these buttons to {Binding SelectedItem, ElementName=listBoxName}. However, I am having a hard time accomplishing this within the ChildView because I do not have access to (and do not want to be dependent on) the element from the parent view. Please help me accomplish this, preferably purely within the XAML code.

  • 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-06-08T21:22:10+00:00Added an answer on June 8, 2026 at 9:22 pm

    You should be able to just check if the datacontext of the childview is null (i.e. no ChildViewModel set). If it is null hide the buttons.

    <Button Click="Button_Click" Content="bah">
            <Button.Style>
                <Style TargetType="Button">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=DataContext}" Value="{x:Null}" >
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
    

    Set the ancestor to whatever container is holding your child view

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

Sidebar

Related Questions

I currently have a view that contains a ListBox bound to a a collection
I have a databound grid at my view (XAML) and the Itemsource points to
I am beginner in rails. I have view that i try to print inside
I have a UserControl which contains a listbox and few buttons. <UserControl x:Class=ItemControls.ListBoxControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I have a ListBox when one of the ListBoxItems are selected I want to
In my XAML file, I have a ListBox declared like this : <ListBox x:Name=lstDeck
I have Listbox which is bound to my view model. This view model has
I`m writing a program to view product Information in a Listbox. I have a
I have a Windows 8 Metro app created in XAML, C# from the template.
I have a XAML view with a list box: <control:ListBoxScroll ItemSource={Binding Path=FooCollection} SelectedItem={Binding SelectedFoo,

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.