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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:29:05+00:00 2026-05-25T16:29:05+00:00

Would it be possible for an Adorner to be hidden / displayed depending on

  • 0

Would it be possible for an Adorner to be hidden / displayed depending on the value of a property in a class ?

Should I use attached properties for this purpose ?

If so, how exactly can the Adorner’s visibility be controlled; do I have to manually remove it / add it to the Adorner Layer within the Dependency Object’s OnChanged event ?

This is just a very quick code representation of what I’m trying to do:

(Note: I’m not even sure if its the right way of doing things. I want the Adorner’s visibility to be controlled by the value of a property that is modified by the code in my business model. The problem with Attached Properties is that its the control’s responsibility to update the value of the property instead of the code in my business domain.)

public static class IsValidBehavior
{
    public static readonly DependencyProperty IsValidProperty = DependencyProperty.RegisterAttached("IsValid",
                                                                    typeof(bool),
                                                                    typeof(IsValidBehavior),
                                                                    new UIPropertyMetadata(false, OnIsValidChanged));

    public static bool GetIsValid(DependencyObject obj)
    {
        return (bool)obj.GetValue(IsValidProperty);
    }
    public static void SetIsValid(DependencyObject obj, bool value)
    {
        obj.SetValue(IsValidProperty, value);
    }

    private static void OnIsValidChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
    {
        UIElement element = dependencyObject as UIElement;

        if (element == null)
            return;

        if ((bool)e.NewValue == true)
        {
            // Display the Adorner
        }
        else
        {
            // Hide the Adorner
        }
    }
}
  • 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-25T16:29:05+00:00Added an answer on May 25, 2026 at 4:29 pm

    Well, if I right understood your question, in WPF you have 2 ways to do that, from code or from XAML. From code, you more or less already did, in XAML you can do something like this, I think:

    Visibility="{Binding Path=MyVisibilityVariant, 
           Converter={StaticResource VisibilityConverter}}
    

    In other words bind it to some property. My general suggestion: is use XAML whenever you can, considering a couple of variants:

    • XAML declaration makes the software very scallable, but also more complex (consider your, or your group cappabilities, somehow doing the stuff in code behind is best, if not only solution available)

    • Consider you deadlines, cause on XAML stuff implementing/debugging/fixing you will spend more time then on code.

    EDIT

    Defining custom Adorder in order to be able to define it in XAML

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

Sidebar

Related Questions

I wonder if there's any way something like this would be possible for value
Would it be possible to write a class that is virtually indistinguishable from an
Would it be possible to add a new operator to the String class that
would be possible to Compare two strings to find Alliteration and Assonance? i use
do you think it would be possible ( legally ) to use the iAd
I was wondering if it would be possible to use jQuery's ajax function to
I read somewhere a while ago that it would be possible to use 32
I was wondering how (if possible) would you access the return value of an
This seems like it would be possible. protected SameObjectTypeAsInputParameterObjectType GetAValue(someObject,TypeOrReturnObjectYouWant){ //check to see if
I have this button image: I was wondering whether it would be possible to

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.