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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:13:10+00:00 2026-05-14T01:13:10+00:00

I have a list of objects in a model. I wish to show elements

  • 0

I have a list of objects in a model. I wish to show elements of the DTO’s in the list in my AccordianItem panels. The model is like this:

public class MyModel 
{ 
    public List<AnimalDTO> Items { get; set; } 

    public MyModel() 
    { 
        Items = new List<AnimalDTO> 
                    { 
                        new AnimalDTO() {Title = "Monkey", ImageUri = "Images/monkey.jpg"}, 
                        new AnimalDTO() {Title = "Cow", ImageUri = "Images/cow.jpg"}, 
                    }; 
    } 
} 
public class AnimalDTO
{
    public string Title { get; set; }
    public string LongDescription { get; set; }
    public string ImageUri { get; set; }
    public string NavigateUri { get; set; }
}

I want to show the image in the background image of AccordianItems and lay the LongDescription over a portion of the image.

If I hard code it, I can get the image in the AccordianItem thus…

<layoutToolkit:AccordionItem x:Name="Item2" Header="Item 2" Margin="0,0,10,0" AccordionButtonStyle="{StaticResource AccordionButtonStyle1}" ExpandableContentControlStyle="{StaticResource ExpandableContentControlStyle1}" HeaderTemplate="{StaticResource DataTemplate1}" BorderBrush="{x:Null}" ContentTemplate="{StaticResource CarouselContentTemplate}">
                <layoutToolkit:AccordionItem.Background>
                    <ImageBrush ImageSource="Images/cow.jpg" Stretch="None"/>
                </layoutToolkit:AccordionItem.Background>
            </layoutToolkit:AccordionItem>

When I try it with a binding like <ImageBrush ImageSource="{Binding Path={StaticResource MyContentTemplate.ImageUri}}" Stretch="None"/> or if I try it with <ImageBrush ImageSource="{Binding Path=Items[0].ImageUri}" Stretch="None"/>
, it throws XamlParseException.

Edit:
I’m able to get some binding of the text over hard-coded images with the following StaticResource (NOTE: I’m hard-coding Items[2], I’m not sure how to index it)

        <DataTemplate x:Key="CarouselContentTemplate">
        <Grid Width="650" Height="420">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.476*"/>
                <RowDefinition Height="0.524*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="0"
                   x:Name="Title" 
                   Text="{Binding Items[2].Title}" 
                   Foreground="Black" FontSize="12"></TextBlock>
            <TextBlock Grid.Row="1" Grid.Column="0"
                   x:Name="LongDescription" 
                   Text="{Binding Items[2].LongDescription}"
                   TextWrapping="Wrap"FontSize="8"></TextBlock>
        </Grid>
    </DataTemplate>

Is there a way to index the Items collection in the DataTemplate? Furthermore how do I get the Image to bind rather than hard-coding them in each AccordianItem? Any help in the right direction would be appreciated, most especially how to bind and lay text over an image.

  • 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-14T01:13:10+00:00Added an answer on May 14, 2026 at 1:13 am

    To bind to a collection it must be referenced with ItemsSource=”{Binding Items}”, where in this case Items is my collection MyModel.Items

    <layoutToolkit:Accordion
            HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
            ExpandDirection="Right" 
            Style="{StaticResource AccordionStyle1}"
            AccordionButtonStyle="{StaticResource AccordionButtonStyle1}"
             MaxHeight="420" MaxWidth="800" 
             ItemsSource="{Binding Items}" Margin="8,0,-8,-12" Grid.Row="3"
            >
            <layoutToolkit:Accordion.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Title}"></TextBlock>
                </DataTemplate>
            </layoutToolkit:Accordion.ItemTemplate>
    

    Note that a collection should be bound with ItemsSource, which is plural as a mnemonic. and individual members of elements are bound within control of <layoutToolkit:Accordian.ItemTemplate> Here I am showing MyCollection.Title in a TextBlock control. I shall update this with full code or a link to my blog for a full example later.

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

Sidebar

Related Questions

I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have a list of objects (mainly int, string, double) And I would like
I have a list of custom objects List and I would like to update
Say I have a list of model objects and a controller object which is
I have a list of Child objects. I would like to be able to
I have a list of model objects: just an example (I'm not really doing
I have a model of objects. I also have a list of options to
I have a strongly-typed view, with a list of custom objects in the model.
I have a list of Objects (the model) that are constantly appended to (similar
I have a list of lm (linear model) objects. How can I select a

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.