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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:20:28+00:00 2026-05-12T20:20:28+00:00

Hi I found this questions How to manipulate WPF GUI based on user roles

  • 0

Hi I found this questions

How to manipulate WPF GUI based on user roles

and apply his answer to my project. I’m implementing the same behavior.

but the thing is the property binding doesn’t work.

I create the RoleToVisibilityConverter class and make some test, calling the convert

RoleToVisibilityConverter conv = new RoleToVisibilityConverter();  
conv.Convert((object)Thread.CurrentPrincipal,cbo_organismo.GetType(),(object)"editor",System.Globalization.CultureInfo.CurrentCulture);

this work find, then i add the resources to my usercontrol

<UserControl.Resources>
<fundafe:RoleToVisibilityConverter x:Key="roleConverter"/>
</UserControl.Resources> 

and make the binding to my button control

<Button Margin="0,0,0,0" Visibility="{Binding Source=Thread.CurrentPrincipal,  Path=CurrentPrincipal, Converter={StaticResource roleConverter}, ConverterParameter=editor}" VerticalAlignment="Center" HorizontalAlignment="Left"  Name="btn_Eliminar" Click="btn_Eliminar_Click" Width="Auto" Height="25" Background="Transparent" BorderBrush="Transparent">
                         <Image Name="img_eliminar" Width="48" Source="imagenes/borrar.png" Height="19" />
                    </Button>

after running my application, the button is still visible.

if i’m hardcoding the Visibility property the button is hidden

btn_Eliminar.Visibility=(Visibility)conv.Convert((object)Thread.CurrentPrincipal,cbo_organismo.GetType(),(object)"editor",System.Globalization.CultureInfo.CurrentCulture)

Any suggestion?

Note:
I’cant use the last approach because in my real scenario the button is part of a DataTemplate for a ListView, and even if a capture the button using the TreeHelper the ListView only apply the change to the first items due to virtualization

  • 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-12T20:20:28+00:00Added an answer on May 12, 2026 at 8:20 pm

    Assuming this is your code verbatim, it looks like the Binding on your Button is wrong. You have this:

    {Binding Source=Thread.CurrentPrincipal,  Path=CurrentPrincipal, Converter={StaticResource roleConverter}, ConverterParameter=editor}
    

    Notice that you’ve bound to Thread.CurrentPrincipal as your source, but then you set the Path to CurrentPrincipal as well. This equates to Thread.CurrentPrincipal.CurrentPrincipal which would obviously fail to bind.

    Honestly I’m pretty sure you need an {x:Static} around the Thread.CurrentPrincipal as well. Plus that means you need a namespace for System.Threading declared. Assuming you define the namespace as “systhreading” so the final binding would be:

    {Binding Source={x:Static systhreading:Thread.CurrentPrincipal},  Converter={StaticResource roleConverter}, ConverterParameter=editor}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I browsed around here on Stackoverflow and found this topic : https://stackoverflow.com/questions/279/aspnet-visual-studio-and-subversion-how-to-integrate However that
I searched and found this question but did not like the answer. Is there
I haven't found an answer to this particular question; perhaps there isn't one. But
Reading this question I found this as (note the quotation marks) code to solve
I found this question in an old question in your website so i thought
Just found this out, so i am answering my own question :) Use a
Similar to this question ... What are the worst practices you actually found in
I've asked this question over on the MSDN forums also and haven't found a
I searched for this and found Maudite's question about text editors but they were
I found this open-source library that I want to use in my Java application.

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.