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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:26:22+00:00 2026-05-27T05:26:22+00:00

Now I have ListView and in one column has: <GridViewColumn CellTemplateSelector={StaticResource messagerEditorTemplateSelector}/> And everything

  • 0

Now I have ListView and in one column has:

<GridViewColumn CellTemplateSelector="{StaticResource messagerEditorTemplateSelector}"/>

And everything is fine: cell is filled with content based on item. But now I want to place in this cell 2 controls: for one template must be selected based on binding and other is control with name, say TimeRangeView. But I cannot understand how it can be implemented? So I must have code like:

<GridViewColumn>
    <DataTemplate>
        <StackPanel>
            <SomeControlWhichSupportTemplateSelector ... />
            <views:TimeRangeView ... />
        </StackPanel>
    </DataTemplate>
</GridViewColumn>`

Which control should I use for template? I’ve found only listbox but it must be bound to collection. Of course, I could bind like:

<ListBox ItemsSource="{Binding Converter=ItemToCollectionConverter}" />

but it doesn’t look elegant. May be there is another way to do it?

  • 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-27T05:26:23+00:00Added an answer on May 27, 2026 at 5:26 am

    You can use a ContentControl and set its ContentTemplateSelector property:

     <GridViewColumn>
        <GridViewColumn.CellTemplate>
            <DataTemplate>
                <StackPanel>
                    <ContentControl ContentTemplateSelector="{StaticResource messagerEditorTemplateSelector}" />
                    <views:TimeRangeView ... />
                </StackPanel>
            </DataTemplate>
          </GridViewColumn.CellTemplate>
        </GridViewColumn>
    

    Note that for Binding to work within your ContentControl, you will have to set the Content property to whichever object is used in the Bindings of the DataTemplate returned by your selector.

    So that’s for option 1.
    You can also just use DataTriggers:

         <GridViewColumn>
            <GridViewColumn.CellTemplate>
                <DataTemplate>
                    <StackPanel>
                      <ContentControl Content="{Binding MyBoundObject}">
                        <ContentControl.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=MyBoundObject.ABooleanProperty}" Value="True">
                                        <Setter Property="ContentControl.ContentTemplate" Value="{StaticResource myFirstTemplate}" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=MyBoundObject.ABooleanProperty}" Value="False">
                                        <Setter Property="ContentControl.ContentTemplate" Value="{StaticResource mySecondTemplate}" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
                    </ContentControl>
                    <views:TimeRangeView ... />
                  </StackPanel>
                </DataTemplate>
              </GridViewColumn.CellTemplate>
            </GridViewColumn>
    

    Which is what i do and it works like a charm =)

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

Sidebar

Related Questions

I have a standard ListView with a GridView . Now I want one of
i have created one listview.now i want to show data(contact no.,name) from contactlist of
A have a ListView that is rendered with multiple items. Now I want to
i have the files situated in the listview now i want to copy those
I have fetched images and text as listview from database.now on clicking the particular
I have a listview which includes 2 textviews and 1 imageview. Now, the image
I have one listview.which contain one image ,text and one button .i had creted
I have one listview that compiles layout template, item template and insert item template.
I have a ListView which I filled in from SQL Server view called view_ListaKlientow
I have a listview with a checkbox, an image and a text field. Now

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.