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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:13:13+00:00 2026-05-13T08:13:13+00:00

I want to achieve the following behavior: Depending on a value use a different

  • 0

I want to achieve the following behavior:
Depending on a value use a different datatemplate:

 <DataTemplate x:Key="cardTemplate2">
                    <Border x:Name="container">
                     .....
                    </Border>

                  <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding ShowSecondDT}" Value="True">
                      <Setter Property="Child" TargetName="container">
                        <Setter.Value>
                            <StackPanel Orientation="Vertical" >

                            </StackPanel>
                        </Setter.Value>
                      </Setter>
                    </DataTrigger>
                  </DataTemplate.Triggers>
                </DataTemplate>

The application fails claiming that Setter Property=”Child” is null…

Another information is that this Datatemplate in the resource of a control: (devexpress gris)

<dxg:GridControl      xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
x:Name="gridTitulaire"        DataSource="{Binding Contacts}" Width="600" >
                <dxg:GridControl.Resources>

                    <DataTemplate x:Key="cardTemplate2">
                    <Border x:Name="container">
                    <StackPanel Orientation="Horizontal" >

                            </StackPanel>
                    </Border>

                  <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding isTitulairePrincipal}" Value="True">
                      <Setter Property="Child" TargetName="container">
                        <Setter.Value>
                            <StackPanel Orientation="Vertical" >

                            </StackPanel>
                        </Setter.Value>
                      </Setter>
                    </DataTrigger>
                  </DataTemplate.Triggers>
                </DataTemplate>

                </dxg:GridControl.Resources>
                <dxg:GridControl.Columns>

                  <dxg:GridColumn FieldName="first_name"/>
                  <dxg:GridColumn FieldName="last_name"/>

                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                  <dxg:CardView  x:Name="view" ShowGroupedColumns="True" CardTemplate="{DynamicResource cardTemplate2}"  />
                </dxg:GridControl.View>
              </dxg:GridControl>

Any idea ?
Thanks
Jonathan

  • 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-13T08:13:13+00:00Added an answer on May 13, 2026 at 8:13 am

    Define two separate data templates (call them CardTemplateV for the vertical one, and CardTemplateH for the horizontal one, for example), and set the CardTemplateSelector to a selector object that checks the discriminating field.

    Example:

    class MyTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var cardData = item as CardData;
            if (cardData == null) return null;
            var dataObject = cardData.DataContext as YourDataType;
            if (dataObject == null) return null;
            if (dataObject.isTitulairePrincipal)
                return (DataTemplate)App.Current.FindResource("CardTemplateV");
            else 
                return (DataTemplate)App.Current.FindResource("CardTemplateH");
        }
    }
    

    In the XAML add the selector to the resource dictionary and reference it from the grid:

    <Window.Resources>
        <local:YourTemplateSelector x:Key="MyTemplateSelector"/>
    </Window.Resources>
    ...
    <dxg:CardView
        x:Name="view" 
        ShowGroupedColumns="True" 
        CardTemplateSelector="{StaticResource MyTemplateSelector}"/>
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to achieve the following behavior in a page link. When the link
I want to achieve the following use the following command to add a column
I want to achieve the following: ID | Counter ------------ 0 | 343 1
I want to achieve the following hierarchical navigation model in a WPF MVVM application:
I have a gridview with couple of columns,I want to achieve the following: If
I want to achieve something like the following: UrlBuilder ub = new UrlBuilder(http://www.google.com/search); ub.Parameters.Add(q,request);
I would like to achieve the following: I want a free Application Lifecycle Management
The following code is almost the same thing I want to achieve. <?xml version=1.0
Is there a way to achieve the following in Maven? I want to exclude
I want to select data from following table group by weeks Date Product Name

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.