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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:28:40+00:00 2026-05-14T04:28:40+00:00

I have a DataTemplate which contains a CheckBox and ListBox. When the CheckBox is

  • 0

I have a DataTemplate which contains a CheckBox and ListBox. When the CheckBox is checked, I want to change the ItemTemplate property on the ListBox to change the appearance of each item.

Right now, it looks like this:

<DataTemplate DataType={x:Type MyViewModel}>
   <DockPanel>       
      <CheckBox DockPanel.Dock="Bottom"
                Content="Show Details"
                HorizontalAlignment="Right"
                IsChecked="{Binding ShowDetails}" 
                Margin="0 5 10 5" />

      <ListBox ItemsSource="{Binding Items}"
               ItemTemplate="{StaticResource SimpleItemTemplate}"
               Margin="10 0 10 5">
         <ListBox.Triggers>
            <DataTrigger Binding="{Binding ShowDetails}" Value="True">
               <Setter Property="ItemTemplate"
                       Value="{StaticResource DetailedItemTemplate}" />
            </DataTrigger>
         </ListBox.Triggers>
      </ListBox>
   </DockPanel>
</DataTemplate>

However, when I try to compile, I get the following error messages:

Value ‘ItemTemplate’ cannot be assigned to property ‘Property’. Invalid PropertyDescriptor value.

and

Cannot find the static member ‘ItemTemplateProperty’ on the type ‘ContentPresenter’.

I’m still fairly new to WPF, so perhaps there is something I’m not quite understanding?

  • 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-14T04:28:41+00:00Added an answer on May 14, 2026 at 4:28 am

    You need to do this through the ListBox Style rather than directly through its Triggers collection. A FrameworkElement’s Triggers collection can only contain EventTriggers (so I’m surprised your sample got as far as complaining about the properties!). Here’s what you need to do:

    <ListBox ItemsSource="{Binding Items}">
      <ListBox.Style>
        <Style TargetType="ListBox">
          <Setter Property="ItemTemplate" Value="{StaticResource SimpleItemTemplate}" />
          <Style.Triggers>
            <DataTrigger Binding="{Binding ShowDetails}" Value="True">
               <Setter Property="ItemTemplate"
                       Value="{StaticResource DetailedItemTemplate}" />
            </DataTrigger>
         </Style.Triggers>
       </Style>
      </ListBox.Style>
    </ListBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello everybody i have a listbox within which is a datatemplate.Inside it is checkbox,textbox,label...Wat
I have a listbox that has a datatemplate which contains multiple text boxes. I
I have a ListBox which contains all the Categories and each category will contain
I have a listbox in which the item source contains a List(of T) that
I have a WPF ListBox which contains a CheckBox as follow: <ListBox x:Name=MyListBox Grid.Row=1
I have a list of items, each of which contains a display property of
I have a Listbox DataTemplate which looks like this <DataTemplate> <StackPanel Margin=0,24,0,24> <StackPanel toolkit:TiltEffect.IsTiltEnabled=true>
I have a ListBox which uses a DataTemplate to render databound items. The XAML
I have a custom UserControl which has a DependencyProperty ItemTemplate of type DataTemplate. I
So I have the following DataTemplate for a ListBox.ItemTemplate : <DataTemplate x:Key=Tweet> <Grid> <Grid.ColumnDefinitions>

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.