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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:44:47+00:00 2026-05-14T00:44:47+00:00

Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I’m learning

  • 0

Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I’m learning about DataTemplating and am trying to apply a very VERY simple ItemTemplate to a ListBox.

However, when I run my app, the template is completely ignored and I just get the standard-looking listbox, whereas in fact I’d expect to see a list of checkboxes with ‘Test’ along side.

I’ve tried this several times and always the same result. I’ve checked several resource on Google and all have the same kind of syntax for defining and ItemTemplate on a ListBox, so I really cannot see where I’m going wrong.

Code…

<Grid x:Name="LayoutRoot">
    <ListBox x:Name="TestList"
        SelectionMode="Multiple">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <CheckBox Content="Check this checkbox!"/>
                    <TextBlock>Test</TextBlock>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.Items>
            <ListBoxItem>Bob</ListBoxItem>
            <ListBoxItem>Jim</ListBoxItem>
            <ListBoxItem>Dave</ListBoxItem>
            <ListBoxItem>Larry</ListBoxItem>
            <ListBoxItem>Tom</ListBoxItem>
        </ListBox.Items>            
    </ListBox>
</Grid>

Any help greatly appreciated. Sorry for such a dumb-seeming question, but I’ve really fallen at the first hurdle here 🙁

AT

  • 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-14T00:44:47+00:00Added an answer on May 14, 2026 at 12:44 am

    ItemTemplate wont work when you put ListBoxItem directly as items. General concept is you databind a CRL collection to the ListBox.ItemsSource and then specify the ItemTemplate. Check the below code.

     <Grid x:Name="LayoutRoot">
            <ListBox x:Name="TestList"  SelectionMode="Multiple">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <CheckBox Content="Check this checkbox!"/>
                            <TextBlock Text="{Binding}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <ListBox.Items>
                    <sys:String>Bob</sys:String>
                    <sys:String>Jim</sys:String>
                    <sys:String>Dave</sys:String>
                    <sys:String>Larry</sys:String>
                    <sys:String>Tom</sys:String>
                </ListBox.Items>
            </ListBox>
        </Grid>
    

    where sys is xmlns:sys="clr-namespace:System;assembly=mscorlib"

    In this way, there are 5 ListBoxItems getting generated in the background and added to the ListBox.

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

Sidebar

Related Questions

This problem is probably embarrassingly simple. I'm trying to give python a spin. I
This has been driving me crazy for 2 days. I have been trying to
This seems to be an embarrassingly simple question, but, after a day of reading
This is a sort of trivial question but something I've been wondering about. In
I'm sure there must be a really simple answer to this, but at the
I know that this is an embarassingly easy question, but I can't figure out
Ok this is embarrassingly simple of a question, but I just can't get this
This is a pretty simple question, and I searched the previous questions but couldn't
This is a bit of a long shot, but if anyone can figure it
This is kinda oddball, but I was poking around with the GNU assembler today

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.