Click here to Skip to main content
14,423,065 members

Silverlight / WPF

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 4:09
cofounderChris Maunder16-Jul-09 4:09 
PinnedHow to get an answer to your question PinPopular
Chris Maunder16-Jul-09 4:05
cofounderChris Maunder16-Jul-09 4:05 
QuestionIm new bie help me fix 1 erorr on wpf, i cant do it? Pin
Member 1468037212-Jan-20 17:07
MemberMember 1468037212-Jan-20 17:07 
GeneralRe: Im new bie help me fix 1 erorr on wpf, i cant do it? Pin
Richard MacCutchan12-Jan-20 23:12
communityengineerRichard MacCutchan12-Jan-20 23:12 
AnswerRe: Im new bie help me fix 1 erorr on wpf, i cant do it? Pin
ZurdoDev13-Jan-20 2:07
mveZurdoDev13-Jan-20 2:07 
QuestionRoutedEvent Pass EventArg Pin
Kevin Marois11-Jan-20 17:42
professionalKevin Marois11-Jan-20 17:42 
AnswerRe: RoutedEvent Pass EventArg Pin
Gerry Schmitz11-Jan-20 21:24
mveGerry Schmitz11-Jan-20 21:24 
GeneralRe: RoutedEvent Pass EventArg Pin
Kevin Marois12-Jan-20 11:05
professionalKevin Marois12-Jan-20 11:05 
GeneralRe: RoutedEvent Pass EventArg Pin
Gerry Schmitz13-Jan-20 14:23
mveGerry Schmitz13-Jan-20 14:23 
GeneralRe: RoutedEvent Pass EventArg Pin
Kevin Marois14-Jan-20 6:18
professionalKevin Marois14-Jan-20 6:18 
GeneralRe: RoutedEvent Pass EventArg Pin
Kevin Marois14-Jan-20 6:43
professionalKevin Marois14-Jan-20 6:43 
AnswerRe: RoutedEvent Pass EventArg Pin
Richard Deeming13-Jan-20 9:00
communityengineerRichard Deeming13-Jan-20 9:00 
GeneralRe: RoutedEvent Pass EventArg Pin
Kevin Marois14-Jan-20 10:02
professionalKevin Marois14-Jan-20 10:02 
QuestionCalculate the textbox value based on the value of combobox ? ( wpf ) Pin
Member 146803727-Jan-20 20:44
MemberMember 146803727-Jan-20 20:44 
QuestionRe: Calculate the textbox value based on the value of combobox ? ( wpf ) Pin
Richard MacCutchan7-Jan-20 22:17
communityengineerRichard MacCutchan7-Jan-20 22:17 
AnswerRe: Calculate the textbox value based on the value of combobox ? ( wpf ) Pin
Member 146803727-Jan-20 22:49
MemberMember 146803727-Jan-20 22:49 
SuggestionRe: Calculate the textbox value based on the value of combobox ? ( wpf ) Pin
Richard Deeming8-Jan-20 1:46
communityengineerRichard Deeming8-Jan-20 1:46 
QuestionRefresh Attached Property? Pin
Kevin Marois7-Jan-20 11:17
professionalKevin Marois7-Jan-20 11: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 2:18
communityengineerRichard Deeming8-Jan-20 2:18 
QuestionWPF Exception - Send Error Report Pin
Kevin Marois30-Dec-19 8:41
professionalKevin Marois30-Dec-19 8:41 
AnswerRe: WPF Exception - Send Error Report Pin
Richard MacCutchan30-Dec-19 11:13
communityengineerRichard MacCutchan30-Dec-19 11:13 
AnswerRe: WPF Exception - Send Error Report Pin
jimmson2-Jan-20 4:15
Memberjimmson2-Jan-20 4:15 
AnswerRe: WPF Exception - Send Error Report Pin
Gerry Schmitz2-Jan-20 21:09
mveGerry Schmitz2-Jan-20 21:09 
AnswerRe: WPF Exception - Send Error Report Pin
Mycroft Holmes3-Jan-20 11:49
MemberMycroft Holmes3-Jan-20 11:49 
QuestionMenuButton CanExecute Firing Wrong Pin
Kevin Marois24-Dec-19 12:42
professionalKevin Marois24-Dec-19 12:42 

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.