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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:37:43+00:00 2026-06-14T15:37:43+00:00

I have a property and depending upon it’s state (say A and B) I

  • 0

I have a property and depending upon it’s state (say A and B) I either show a usercontrol of animation or a image.

Now, if the property changes, I want to trigger the datatemplate selector again. On searching, I found that in WPF I could have used DataTemplate.Trigger but it’s not available in WP.

So, my question is

  • Is their a way to trigger datatemplate selector so when property changes from state A to B, then appropriate usercontrol gets selected. If yes, then please give some example how to implement it.

Also, as there are only two states, if think I can use Converter to collapse the visibility. For basic if else situation, I will need to write two converters.( Can I somehow do it using one converter only?)
Here is the exact situation.

If state == A :

select userControl_A

else : select userControl_B

Also,

  • Will the animation usercontrol will effect the performance when it’s in Collapsed state?

EDIT– Just realized, I can use parameter object to write just one converter.

  • 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-14T15:37:44+00:00Added an answer on June 14, 2026 at 3:37 pm

    You could implement a DataTemplateSelector like described here.
    I use it and it works pretty well.

    EDIT:
    If you need to update the DataTemplate when the property changes, you should subscribe to the PropertyChanged event of the data object in the TemplateSelector and execute the SelectTemplate method again.

    Here is the code sample:

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        City itemAux = item as City;
    
        // Subscribe to the PropertyChanged event
        itemAux.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(itemAux_PropertyChanged);
    
        return GetTemplate(itemAux, container);
    }
    
    private DataTemplate GetTemplate(City itemAux, DependencyObject container)
    {
        if (itemAux != null)
        {
            if (itemAux.Country == "Brazil")
                return BrazilTemplate;
            if (itemAux.Country == "USA")
                return UsaTemplate;
            if (itemAux.Country == "England")
                return EnglandTemplate;
        }
    
        return base.SelectTemplate(itemAux, container);
    }
    
    void itemAux_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        // A property has changed, we need to reevaluate the template
        this.ContentTemplate = GetTemplate(sender as City, this);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a property that can be nullable or required depending on the status
I have a program that creates UIViewControllers in a UISplitView depending upon which row
So I have a panel and depending upon users entry they are populated with
I have a property configuration depending on my environment, like this: <bean id=someConfigurer class=org.springframework.beans.factory.config.PropertyPlaceholderConfigurer>
I have a public readonly property that calculates its value based upon a couple
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I have a property in my backing bean that returns html code: public String
I have a property in my view model which returns a constant under some
I have a property an NSArray property called toolbarButtons that in one instance (when

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.