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

The Archive Base Latest Questions

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

I am making my first gui in C# and I have watched/read a ton

  • 0

I am making my first gui in C# and I have watched/read a ton of tutorials about WPF and MVVM(that’s the approach I’m using), but I am stuck on something that intuitively should be rather simple to accomplish. I have a listbox, and above it I would like to display a textblock or label that would say “Please select item from list” and then disappear once an item is selected.

How can I accomplish this? Would it require writing in the code-behind? Most tutorials I have read discourage ever using the code-behind so I would prefer a different solution. I assume this is not possible to do directly from within XAML, so would I need to create a ViewModel variable to hold the listbox state?? If so, then how could I make a textblock/label dependent on a variable?

  • 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:59:00+00:00Added an answer on June 8, 2026 at 9:59 pm

    For doing this in XAML only

    <StackPanel>
        <TextBlock Text="Please select an item!">
            <TextBlock.Style>
                <Style TargetType="TextBlock">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding SelectedItem, ElementName=lb}" Value="{x:Null}">
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
        </TextBlock>
        <ListBox Name="lb" ItemsSource="12345" />
    </StackPanel>
    

    ItemsSource="12345" will create five rows for demonstration only.

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

Sidebar

Related Questions

I am making my first program using Java3D. I have setup some transformGroups that
I have just made my first proper little desktop GUI application that basically wraps
I am making my first ever C# GUI. It is using a BackgroundWorker to
I have a matlab gui that shall contain 4 plots. The first plot shall
I'm making my first steps with unit testing and am unsure about two paradigms
The sampled code below is for the GUI I am currently making. I have
I am making a GUI using SpringLayout using the following code: private void createAndShowGUI()
I have 2 questions. So i am making a python program that will backup
I'm using eclipse Indigo and I'm making GUI, I've decided to use MigLayout cause
I have been asked to write a GUI that will allow objects to be

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.