Click here to Skip to main content
15,902,112 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa10-Sep-20 15:56
Rusdy Perkasa10-Sep-20 15:56 
GeneralRe: load usercontrol in background worker Pin
Dave Kreskowiak10-Sep-20 16:29
mveDave Kreskowiak10-Sep-20 16:29 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa10-Sep-20 17:15
Rusdy Perkasa10-Sep-20 17:15 
GeneralRe: load usercontrol in background worker Pin
Dave Kreskowiak10-Sep-20 18:02
mveDave Kreskowiak10-Sep-20 18:02 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa10-Sep-20 18:41
Rusdy Perkasa10-Sep-20 18:41 
GeneralRe: load usercontrol in background worker Pin
Dave Kreskowiak11-Sep-20 2:32
mveDave Kreskowiak11-Sep-20 2:32 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa11-Sep-20 17:13
Rusdy Perkasa11-Sep-20 17:13 
GeneralRe: load usercontrol in background worker Pin
Dave Kreskowiak11-Sep-20 18:36
mveDave Kreskowiak11-Sep-20 18:36 
GeneralRe: load usercontrol in background worker Pin
Gerry Schmitz11-Sep-20 9:29
mveGerry Schmitz11-Sep-20 9:29 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa11-Sep-20 17:20
Rusdy Perkasa11-Sep-20 17:20 
GeneralRe: load usercontrol in background worker Pin
Mycroft Holmes11-Sep-20 12:20
professionalMycroft Holmes11-Sep-20 12:20 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa11-Sep-20 17:27
Rusdy Perkasa11-Sep-20 17:27 
GeneralRe: load usercontrol in background worker Pin
Gerry Schmitz11-Sep-20 18:14
mveGerry Schmitz11-Sep-20 18:14 
GeneralRe: load usercontrol in background worker Pin
Rusdy Perkasa11-Sep-20 18:28
Rusdy Perkasa11-Sep-20 18:28 
GeneralRe: load usercontrol in background worker Pin
Gerry Schmitz12-Sep-20 4:47
mveGerry Schmitz12-Sep-20 4:47 
GeneralRe: load usercontrol in background worker Pin
Eddy Vluggen12-Sep-20 8:44
professionalEddy Vluggen12-Sep-20 8:44 
QuestionCan we add animation to WPF just like we have SHAPE animation in powerpoint? Pin
User-86216959-Jul-20 23:57
User-86216959-Jul-20 23:57 
QuestionVertical text in WPF grid Pin
kalberts6-Jul-20 8:54
kalberts6-Jul-20 8:54 
AnswerRe: Vertical text in WPF grid Pin
Gerry Schmitz6-Jul-20 12:10
mveGerry Schmitz6-Jul-20 12:10 
AnswerRe: Vertical text in WPF grid Pin
Richard Deeming6-Jul-20 23:43
mveRichard Deeming6-Jul-20 23:43 
GeneralRe: Vertical text in WPF grid Pin
kalberts7-Jul-20 5:03
kalberts7-Jul-20 5:03 
QuestionBehavior/DP Question Pin
Kevin Marois22-Jun-20 8:27
professionalKevin Marois22-Jun-20 8:27 
AnswerRe: Behavior/DP Question Pin
Richard Deeming23-Jun-20 4:44
mveRichard Deeming23-Jun-20 4:44 
It's an attached property, so you need to either call the attached property accessor, or call GetValue and pass in the dependency property.

Try something like this:
C#
public static class SecurityBehavior
{
    private static readonly char[] TagSeparators = { '|' };
    
    public static readonly DependencyProperty SecurityTagsProperty =
        DependencyProperty.RegisterAttached("SecurityTags",
        typeof(string), typeof(SecurityBehavior),
        new PropertyMetadata("", OnSecurityChanged));
    
    public static string GetSecurityTags(DependencyObject obj)
    {
        return (string)obj.GetValue(SecurityTagsProperty);
    }

    public static void SetSecurityTags(DependencyObject obj, string value)
    {
        obj.SetValue(SecurityTagsProperty, value);
    }

    public static readonly DependencyProperty AllowEnableProperty =
        DependencyProperty.RegisterAttached("AllowEnable",
        typeof(bool), 
        typeof(SecurityBehavior),
        new PropertyMetadata(false, OnSecurityChanged));

    public static bool GetAllowEnable(DependencyObject obj)
    {
        return (bool)obj.GetValue(AllowEnableProperty);
    }

    public static void SetAllowEnable(DependencyObject obj, bool value)
    {
        obj.SetValue(AllowEnableProperty, value);
    }
    
    private static void OnSecurityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
    {
        bool canEnable = GetAllowEnable(sender);
        if (canEnable)
        {
            string[] tags = GetSecurityTags(sender).Split(TagSeparators, StringSplitOptions.RemoveEmptyEntries);
            foreach (string tag in tags)
            {
                canEnable &= SecurityService.HasRights(tag);
            }
        }
    
        var element = (UIElement)sender;
        element.IsEnabled = canEnable;
    }




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Behavior/DP Question Pin
Kevin Marois1-Jul-20 8:30
professionalKevin Marois1-Jul-20 8:30 
GeneralRe: Behavior/DP Question Pin
Richard Deeming1-Jul-20 23:32
mveRichard Deeming1-Jul-20 23:32 

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.