Click here to Skip to main content
14,669,152 members
Home » Discussions » Silverlight / WPF
   

Silverlight / WPF

 
GeneralRe: RoutedEvent Pass EventArg Pin
Kevin Marois14-Jan-20 5:43
professionalKevin Marois14-Jan-20 5:43 
AnswerRe: RoutedEvent Pass EventArg Pin
Richard Deeming13-Jan-20 8:00
mveRichard Deeming13-Jan-20 8:00 
GeneralRe: RoutedEvent Pass EventArg Pin
Kevin Marois14-Jan-20 9:02
professionalKevin Marois14-Jan-20 9:02 
QuestionCalculate the textbox value based on the value of combobox ? ( wpf ) Pin
Member 146803727-Jan-20 19:44
MemberMember 146803727-Jan-20 19:44 
QuestionRe: Calculate the textbox value based on the value of combobox ? ( wpf ) Pin
Richard MacCutchan7-Jan-20 21:17
mveRichard MacCutchan7-Jan-20 21:17 
AnswerRe: Calculate the textbox value based on the value of combobox ? ( wpf ) Pin
Member 146803727-Jan-20 21:49
MemberMember 146803727-Jan-20 21:49 
SuggestionRe: Calculate the textbox value based on the value of combobox ? ( wpf ) Pin
Richard Deeming8-Jan-20 0:46
mveRichard Deeming8-Jan-20 0:46 
QuestionRefresh Attached Property? Pin
Kevin Marois7-Jan-20 10:17
professionalKevin Marois7-Jan-20 10:17 
I created an AttachedProperty to handle enabling/disable UI elements based on a user's access rights:
public static class UIElementEnablerExtension
{
    public static string GetSecurityKey(DependencyObject obj)
    {
        return (string)obj.GetValue(SecurityKeyProperty);
    }

    public static void SetSecurityKey(DependencyObject obj, string value)
    {
        obj.SetValue(SecurityKeyProperty, value);
    }

    public static readonly DependencyProperty SecurityKeyProperty =
        DependencyProperty.RegisterAttached(
            "SecurityKey", typeof(string), typeof(UIElementEnablerExtension),
            new UIPropertyMetadata("", OnSecurityKeyPropertyChanged));

    private static void OnSecurityKeyPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
    {
        // If the current user has been set
        if (AppCore.CurrentUser != null)                   // AppCore is a static class
        {
            // Get the new value set in the XAML
            var accessKey = (string)e.NewValue;

            // If the key was set in the XAML...
            if (!string.IsNullOrEmpty(accessKey))
            {
                // Get the element
                var element = (UIElement)d;

                // Check the user to see if the access code is there
                var hasAccess = AppCore.CurrentUser.Rights.Any(x => x.CompareTo(accessKey) == 0);

                // Enable/Disable the element accordingly
                element.IsEnabled = hasAccess;
            }
        }
    }
}
Usage
<Button Content="Can Do Something"
        Command="{Binding MyCommand"}
        cls:UIElementEnablerExtension.SecurityKey="canUpdate"/>

The problem is that this fires long before the user is prompted to login. how cann I refresh this, or fire it again AFTER the user has logged in?

Or, does anyone have a better approach?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 7-Jan-20 16:59pm.

AnswerRe: Refresh Attached Property? Pin
Richard Deeming8-Jan-20 1:18
mveRichard Deeming8-Jan-20 1:18 
QuestionWPF Exception - Send Error Report Pin
Kevin Marois30-Dec-19 7:41
professionalKevin Marois30-Dec-19 7:41 
AnswerRe: WPF Exception - Send Error Report Pin
Richard MacCutchan30-Dec-19 10:13
mveRichard MacCutchan30-Dec-19 10:13 
AnswerRe: WPF Exception - Send Error Report Pin
jimmson2-Jan-20 3:15
Memberjimmson2-Jan-20 3:15 
AnswerRe: WPF Exception - Send Error Report Pin
Gerry Schmitz2-Jan-20 20:09
mveGerry Schmitz2-Jan-20 20:09 
AnswerRe: WPF Exception - Send Error Report Pin
Mycroft Holmes3-Jan-20 10:49
professionalMycroft Holmes3-Jan-20 10:49 
QuestionMenuButton CanExecute Firing Wrong Pin
Kevin Marois24-Dec-19 11:42
professionalKevin Marois24-Dec-19 11:42 
AnswerRe: MenuButton CanExecute Firing Wrong Pin
Gerry Schmitz26-Dec-19 6:34
mveGerry Schmitz26-Dec-19 6:34 
GeneralRe: MenuButton CanExecute Firing Wrong Pin
Kevin Marois26-Dec-19 7:38
professionalKevin Marois26-Dec-19 7:38 
GeneralRe: MenuButton CanExecute Firing Wrong Pin
Gerry Schmitz27-Dec-19 5:58
mveGerry Schmitz27-Dec-19 5:58 
AnswerRe: MenuButton CanExecute Firing Wrong Pin
Mycroft Holmes27-Dec-19 14:21
professionalMycroft Holmes27-Dec-19 14:21 
GeneralRe: MenuButton CanExecute Firing Wrong Pin
Kevin Marois27-Dec-19 14:34
professionalKevin Marois27-Dec-19 14:34 
GeneralRe: MenuButton CanExecute Firing Wrong Pin
Mycroft Holmes27-Dec-19 14:48
professionalMycroft Holmes27-Dec-19 14:48 
GeneralRe: MenuButton CanExecute Firing Wrong Pin
Kevin Marois27-Dec-19 14:53
professionalKevin Marois27-Dec-19 14:53 
GeneralRe: MenuButton CanExecute Firing Wrong Pin
Mycroft Holmes27-Dec-19 15:20
professionalMycroft Holmes27-Dec-19 15:20 
AnswerRe: MenuButton CanExecute Firing Wrong Pin
Richard Deeming7-Jan-20 8:53
mveRichard Deeming7-Jan-20 8:53 
AnswerMessage Closed Pin
9-Jan-20 11:33
Memberamcic19909-Jan-20 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.