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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:12:50+00:00 2026-05-27T12:12:50+00:00

I have already looked into this solution: Show if ItemsControl.ItemsSource is null . I

  • 0

I have already looked into this solution: Show if ItemsControl.ItemsSource is null.
I set the DataContext of the ItemsControl via codebehind to an ObservableCollection. Everything works fine except that it only resolves once during the loading phase. If the items control has a few items in the start, the text disappears but doesn’t appear later onwards. If it’s empty, the text appears, but it doens’t go away when i add items later on. I have tried ItemsSource as well but no luck. I’m aware im using a control template as of now, and i can use relative source TemplatedParent but i just wanted to make sure. Upon further testing, the converter function doesn’t seem to activate after i try to add/remove items in the list even though the items show on my itemscontrol.

<ItemsControl x:Name="MedicationList" ItemTemplate="{StaticResource UserTemplate}">
  <ItemsControl.Template>
    <ControlTemplate TargetType="ItemsControl">
      <Grid>
        <TextBlock Text="No Items to Display" Visibility="{Binding DataContext, ElementName=MedicationList, Converter={StaticResource AnyItemsToVisibilityConverter}}" />
        <ItemsPresenter />
      </Grid>
    </ControlTemplate>     
  </ItemsControl.Template>
</ItemsControl>
  • 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-27T12:12:51+00:00Added an answer on May 27, 2026 at 12:12 pm

    What are you using as the datacontext/itemssource? If it is an ObservableCollection as I would expect, then you would be best off binding to its “Count” property and then using a trigger to collapse the text block when necessary.

    The reason that the binding isn’t currently updating is that the DataContext itself isn’t actually changing. Properties on the DataContext ARE changing, so if you bind to the correct property (count) your bindings will update.

    This code snippet should work:

    <ControlTemplate TargetType="ItemsControl">
      <Grid>
        <TextBlock x:Name="txtBlock" Text="No Items to Display" Visibility="Collapsed" />
        <ItemsPresenter />
      </Grid>
      <ControlTemplate.Triggers>
        <DataTrigger Binding="{Binding Path=Count}" Value="0">
          <Setter TargetName="txtBlock" Property="Visibility" Value="Visible"/>
        </DataTrigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>  
    

    By using a data trigger you can avoid the need for a converter to convert a numeric value into a visibility and keep everything in your .xaml.

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

Sidebar

Related Questions

Ok so i have looked and looked for a solution to this but havnt
I have already looked into ANSI escape codes, but it looks like only underlining
I have already looked at other related questions, and none of them helped this
i know, similar questions have been asked, and i've already looked through everything i
I have already googled for this I have a Table with following structure in
I have already created a webpart to show the data from list, but I
I have already posted a question about this, but the situation has changed sufficiently
I have already have this code to force these URLs to HTTPS: RewriteCond %{HTTPS}
Before I posted this question, I already looked this , but I couldn't get
I have already posted something similar here but I would like to ask the

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.