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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:26:58+00:00 2026-06-16T00:26:58+00:00

I have an ItemsControl whose ItemsSource is bound to an XML data provider. The

  • 0

I have an ItemsControl whose ItemsSource is bound to an XML data provider. The code looks like this.

<ItemsControl Grid.Row="1" Margin="30"
              ItemsSource="{Binding Source={StaticResource VideosXML}, 
              XPath=TutorialVideo}" >
  <ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
      <WrapPanel/>
    </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>
  <ItemsControl.ItemTemplate>
    <DataTemplate>
      <Button Style="{StaticResource StyleMetroVideoButton}" 
              Content="{Binding XPath=@Name}"
              ToolTip="{Binding XPath=Description}"/>
    </DataTemplate>
  </ItemsControl.ItemTemplate>                        
</ItemsControl>

VideosXML is an XML data provider referencing an external XML file. As you can see the Name attributes apply to the buttons’ content and the Description elements in the xml file apply to the tooltips of the buttons. Below is the code for the button’s style. It basically is a textblock with a faded “Play” button over the top of it.

<Style TargetType="{x:Type Button}" x:Key="StyleMetroVideoButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid Name="PlayGrid" Background="#FF323236">
                        <TextBlock TextWrapping="Wrap" Text="{TemplateBinding Content}" VerticalAlignment="Top" HorizontalAlignment="Center"/>
                        <Image Name="Play" Source="{StaticResource BtnVideoPlayHoverPNG}"  Opacity="0.0" Stretch="None"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Opacity" Value="0.6" TargetName="Play"/>
                            <Setter Property="Background" Value="#8D8D94" TargetName="PlayGrid"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Source" Value="{StaticResource BtnVideoPlayClickPNG}" TargetName="Play"/>
                            <Setter Property="Opacity" Value="0.6" TargetName="Play"/>
                            <Setter Property="Background" Value="#8D8D94" TargetName="PlayGrid"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.0" TargetName="Play"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Width" Value="90" />
        <Setter Property="Height" Value="80" />
        <Setter Property="Margin" Value="5,5,5,5"/>
    </Style>

You can see from the style that the “Text” in the TextBlock is bound to the content of the button itself: Text=”{TemplateBinding Content}”, and from the first piece of code the Content of the button is bound to an XML element via XPath. However, no text is shown at all. It works if I hard code something in the button like Content=”A Button” will show. Also the tooltip is working fine so I know its reading data from the XML file. So what makes binding to XPath different than hard coding a value?

Thanks in advance for looking at my question!

EDIT: Sample XML

<?xml version="1.0" encoding="utf-8" ?>
<Videos xmlns="">
  <TutorialVideo Name="Video 1">
    <Description>A video to watch</Description>
    <Filepath>video1.wmv</Filepath>
  </TutorialVideo>
</Videos>
  • 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-16T00:26:58+00:00Added an answer on June 16, 2026 at 12:26 am

    Ok, I found the problem, for some reason the Content property is passing the whole xml element, setting the Content binding to Content="{Binding XPath=@Name, Path=Value}" should fix the issue

    There is probably a logical explaination for this, Google will know

    <ItemsControl Grid.Row="1" Margin="30"
                  ItemsSource="{Binding Source={StaticResource VideosXML}, 
                  XPath=TutorialVideo}" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Button Style="{StaticResource StyleMetroVideoButton}"  
                                Content="{Binding XPath=@Name, Path=Value}"  
                                ToolTip="{Binding XPath=Description}"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ItemsControl set up like this: <Grid> <ItemsControl ItemsSource={Binding Asteroids}> <ItemsControl.ItemsPanel> <ItemsPanelTemplate>
I have ItemsControl with DataTemplate that looks like this: I want to achieve effect
I have an ItemsControl whose ItemsSource gets bound to an ObservableCollection<Component> at run time.
I have a WPF ItemsControl who's ItemsSource is bound to an observable collection of
I have an ItemsControl containing a list of data that I would like to
I have a ItemsControl bound to a string list. Code:- List<string> possibleAnswers; possibleAnswers =
I have ItemsControl with VirtualizingStackPanel as items panel like this: <ItemsControl Style={StaticResource ItemsControl} Name=itemsControl
I have ItemsControl with Grid as ItemsPanelTemplate <ItemsControl ItemsSource={Binding CellCollection} Name=CellGrid> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid
I have ItemsControl which is bound and creates multiple Polylines, one for each data
I have an ItemsControl that is data bound to a list of decimal s.

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.