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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:17:09+00:00 2026-06-08T05:17:09+00:00

I have some user admin functionality in a WPF app that I’m currently writing

  • 0

I have some user admin functionality in a WPF app that I’m currently writing and would like to make it a bit more intuitive for the end user

I’d like to be able to provide some kind of means of easily editing the list of roles a given user belongs to. At the moment the grid is filled as a result of binding to a List<ApplicationUser>

ApplicationUser is my own class defined as:

public class ApplicationUser
{
        public Guid? UserId { get; set; }
        public string GivenName { get; set; }
        public string Surname { get; set; }
        public string EmailAddress { get; set; }
        public string UserPhone { get; set; }
        public string NtLoginName { get; set; }
        public List<Role> ApplicationRoles { get; set; }
}

As can be seen the roles that the user is in are held in a List<Role>. Role is my own class defined as:

public class Role
{
   public Guid RoleId;
   public string RoleName;
   public string RoleDescription;
}

The below mockup represents the current state where I just get the roles as a List and through the use of a converter just display the roles as new-line separated strings in the gridview

Current state of gridview

However this is what I’d like to achieve to make toggling off and on membership of various groups easier.

Desired state of gridview

Now that I think about it I’ll probably have to change the definition of Role to include an IsMember property to facilitate binding on the checkbox but if anybody has a better way I’ll welcome that as well. I can change the JOIN type in the sproc so I get back all roles with a query about a particular user and fill the IsMember property accordingly.

Thanks for your time!

  • 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-08T05:17:10+00:00Added an answer on June 8, 2026 at 5:17 am

    Here is a short piece of code I’ve whipped up to get you started. I’ve assumed that you can hydrate IsMember property of Role class when you create the application user. I’ve taken the easiest route by having all roles in all users (enum flags would have been best but given your data, I’m not sure that’s an option without some plumbing). I’ve used minimal columns to get the idea across. If you implement INotifyPropertyChanged on Roles at least, you can hook up to the notification and persist it back into database when the check-boxes change on front end.


    Main Xaml

    <DataGrid DataContext="{StaticResource ResourceKey=AllUsers}" ItemsSource="{Binding}" AutoGenerateColumns="False">
            <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding GivenName}" />
            <DataGridTextColumn Binding="{Binding Surname}" />
            <DataGridTemplateColumn>
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ItemsControl ItemsSource="{Binding ApplicationRoles}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Content="{Binding RoleName}" IsChecked="{Binding IsMember, Mode=TwoWay}" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
    

    Data Xaml

    <x:Array x:Key="AllUsers" Type="Sample:ApplicationUser">
        <Sample:ApplicationUser GivenName="Andrew" Surname="Fuller">
            <Sample:ApplicationUser.ApplicationRoles>
                <Sample:Role RoleName="Administrators" IsMember="True"/>
                <Sample:Role RoleName="Shift Analysts"/>
                <Sample:Role RoleName="Shift Managers" IsMember="True"/>
            </Sample:ApplicationUser.ApplicationRoles>
        </Sample:ApplicationUser>
        <Sample:ApplicationUser GivenName="Anne" Surname="Dodsworth">
            <Sample:ApplicationUser.ApplicationRoles>
                <Sample:Role RoleName="Administrators"/>
                <Sample:Role RoleName="Shift Analysts" IsMember="True"/>
                <Sample:Role RoleName="Shift Managers" IsMember="True"/>
            </Sample:ApplicationUser.ApplicationRoles>
        </Sample:ApplicationUser>
    </x:Array>
    

    Class definitions

    public class ApplicationUser
    {
        public Guid? UserId { get; set; }
        public string GivenName { get; set; }
        public string Surname { get; set; }
        public string EmailAddress { get; set; }
        public string UserPhone { get; set; }
        public string NtLoginName { get; set; }
        public List<Role> ApplicationRoles { get; set; }
    
        public ApplicationUser()
        {
            ApplicationRoles = new List<Role>();
        }
    }
    
    public class Role
    {
        public Guid RoleId { get; set; }
        public string RoleName { get; set; }
        public string RoleDescription { get; set; }
    
        public bool IsMember { get; set; }
    }
    

    Result

    Screenshot

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

Sidebar

Related Questions

I have some items that I'd like the user to be able to filter
I have an admin system and a user system on my website. Some data
I have some user-submitted variables that I want to display in a different part
I have a page with some user selectable options and a button that, when
I have some code that gets the current logged in user. userID = request.session.get(_auth_user_id)
I would like to have functionality on my site where I could display short
I have some XML to work with, something like this: <admin_list> <admin> <name>user1</name> <authentication_source>Local</authentication_source>
I'm trying to write some code that will be run by the 'admin' user
Let's say I have some models: User , Post , and Vote . A
I have some activity were user goes through it and finally send the selected

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.