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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:06:49+00:00 2026-05-23T15:06:49+00:00

I have Preferences data structure where I have string Value field and enum for

  • 0

I have “Preferences” data structure where I have string “Value” field and enum for “Type” field.

Type can be 0-Boolean, 1-Integer, 2-String …

Depending on value in this Type field I’d like to display “Value” cell different way Checkbox, Textbox, dropdown, etc. So, to make it clear – same column should display different cells depending on data in that row..

I guess I need to employ DataGridTemplateColumn but I never did that and would like some example if possible.

Also, what can I do with XAML and what needs to be done in Code? I guess Value converter will have to be used as well?

  • 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-23T15:06:50+00:00Added an answer on May 23, 2026 at 3:06 pm
               <DataGrid ItemsSource="{Binding Items,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
                <DataGrid.Columns>
                    <DataGridTemplateColumn>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ContentControl x:Name="content" Content="{Binding}" >
                                </ContentControl>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding ItemType}" Value="0">
                                        <Setter TargetName="content" Property="ContentTemplate">
                                            <Setter.Value>
                                                <DataTemplate>
                                                    <CheckBox IsChecked="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></CheckBox>
                                                </DataTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding ItemType}" Value="1">
                                        <Setter TargetName="content" Property="ContentTemplate">
                                            <Setter.Value>
                                                <DataTemplate>
                                                    <TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBox>
                                                </DataTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
    

    In CodeBehind you have a ObservableCollection Items {get;set;}

    public class SimpleClass
    {
    public TypeEnum ItemType{get;set;}
    public object Value {get;set;}
    }

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

Sidebar

Related Questions

I have sqlite3 database with example structure and data: CREATE TABLE person(id INTEGER PRIMARY
I have this Linked Web(?) data structure ie. each object has a bunch of
Apologies in advance for the length of this question! I have a data structure
I would like some of my preferences to have icons, like the Settings app.
I have this textbox I use to capture keyboard shortcuts for a preferences config.
If have a union that currently foresees some simple data types: union Value {
I have a C# data structure which consists of classes and collections which have
I need to perform normalization on data structure. I have one table with lots
Related: Does java have a "LinkedConcurrentHashMap" data structure? I am looking for a collection
In .Net/C# Application, I have data structures which have references to each other. 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.