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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:23:08+00:00 2026-05-21T07:23:08+00:00

I’m having hard times with a simple textbox not displaying what I want. Basically

  • 0

I’m having hard times with a simple textbox not displaying what I want.
Basically I have a grouped listbox from this data file xml :

<Hosts>
  <Host foo="aaa">
    <usable>1</usable>
  </Host>
  <Host foo="bbb">
    <usable>1</usable>
  </Host>
</Hosts> 

I have the following code then :

<CollectionViewSource x:Key="cvs"
                      Source="{Binding Source={StaticResource HostsData}}">
    <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="@foo" />
    </CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
<DataTemplate x:Key="categoryTemplate">
    <TextBlock Text="test"
               FontWeight="Bold"
               Background="Gold"
               Margin="0,5,0,0" />
</DataTemplate> 

...

<ListBox Name="myList"
         Grid.Row="0"
         Grid.Column="1"
         TextBlock.FontSize="9"
         Margin="2"
         ItemsSource="{Binding Source={StaticResource cvs}}"
         ItemTemplate="{StaticResource MachinesTemplate}">
    <ListBox.GroupStyle>
        <GroupStyle HeaderTemplate="{StaticResource categoryTemplate}" />
    </ListBox.GroupStyle>
</ListBox>

So I have my grouped listbox, but the testbox content is empty. It’s “gold” and if I setup Text=”test” it’s bolded as it’s supposed to, but I can’t get it to display the “foo” content (aaa, bbb).

I’ve tried all sort of binding without success so far..

  • 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-21T07:23:08+00:00Added an answer on May 21, 2026 at 7:23 am

    To get the text of the matched property you need to bind to the Name property inside the GroupStyle HeaderTemplate:

    <TextBlock Text="{Binding Path=Name}" ... />
    

    Getting to that point assumes that all of your XPaths are working properly, which is a whole other set of issues. Here’s a full working simplified example with the relevant parts from your code:

    <Grid>
        <Grid.Resources>
            <XmlDataProvider x:Key="HostsData"
                             XPath="//Host">
                <x:XData>
                    <Hosts xmlns="">
                        <Host foo="aaa">
                            <usable>1</usable>
                        </Host>
                        <Host foo="bbb">
                            <usable>1</usable>
                        </Host>
                    </Hosts>
                </x:XData>
            </XmlDataProvider>
            <CollectionViewSource x:Key="cvs"
                                  Source="{Binding Source={StaticResource HostsData}}">
                <CollectionViewSource.GroupDescriptions>
                    <PropertyGroupDescription PropertyName="@foo" />
                </CollectionViewSource.GroupDescriptions>
            </CollectionViewSource>
            <DataTemplate x:Key="categoryTemplate">
                <TextBlock Text="{Binding Path=Name}"
                           FontWeight="Bold"
                           Background="Gold"
                           Margin="0,5,0,0" />
            </DataTemplate>
        </Grid.Resources>
        <ListBox Name="myList"
                 ItemsSource="{Binding Source={StaticResource cvs}}">
            <ListBox.GroupStyle>
                <GroupStyle HeaderTemplate="{StaticResource categoryTemplate}" />
            </ListBox.GroupStyle>
        </ListBox>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

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.