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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:59:05+00:00 2026-05-27T21:59:05+00:00

I need to pass some parameters between adorner and adorned control. How this can

  • 0

I need to pass some parameters between adorner and adorned control.

How this can be done? Should I remove and add new adorner with new parameters every time parameters change?

For example, one of my parameters:

    public static readonly DependencyProperty ThetaProperty =
        DependencyProperty.Register("Theta", typeof (double), typeof (SplitControl), new PropertyMetadata(default(double), SetTheta));

    public double Theta
    {
        get { return (double) GetValue(ThetaProperty); }
        set { SetValue(ThetaProperty, value); }
    }

    private static void SetTheta(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        _adorner.Theta = (double) e.NewValue;
    }

In adorner Theta:

    public double Theta
    {
        get
        {
            return (Math.Atan(((_middleTop - _middleBottom) / AdornedElement.DesiredSize.Height))) * 180 / Math.PI;
        }
        set
        {
            double deltaX = (Math.Tan((Math.PI/180)*value))*(AdornedElement.DesiredSize.Height/2);
            _middleTop = _middle + deltaX;
            _middleBottom = _middle - deltaX;
        }
    }
  • 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-27T21:59:06+00:00Added an answer on May 27, 2026 at 9:59 pm

    Here’s a sample (type something into the textbox and watch the adorner):

    Code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Globalization;
    
    namespace Adorners
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
    
                this.Loaded += (o, e) => 
                {
                    AdornerLayer layer = AdornerLayer.GetAdornerLayer(this.t);
    
                    MyAdorner myAdorner = new MyAdorner(this.t);
    
                    layer.Add(myAdorner);
    
                    this.t.Text = "Modified Value";
                };
            }
        }
    
    
        public class MyAdorner : Adorner
        {
            public static DependencyProperty TextProperty =
                DependencyProperty.Register("Text",
                typeof(string),
                typeof(MyAdorner),
                new PropertyMetadata("Default Text", 
                (o, e) => 
                {
                    ((MyAdorner)o).InvalidateVisual();
                }));
    
            // Be sure to call the base class constructor.
            public MyAdorner(UIElement adornedElement)
                : base(adornedElement)
            {
                this.DataContext = this.AdornedElement;
    
                this.SetUpBindings();
            }
    
            private void SetUpBindings()
            {
                BindingOperations.SetBinding(this,
                   MyAdorner.TextProperty,
                   new Binding()
                   {
                       Path = new PropertyPath("Text"),
                       UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                   });
            }
    
            public string Text
            {
                get { return (string)this.GetValue(MyAdorner.TextProperty); }
                set { this.SetValue(MyAdorner.TextProperty, value); }
            }
    
            protected override void OnRender(DrawingContext drawingContext)
            {
                Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
    
                drawingContext.DrawText(new FormattedText(this.Text, CultureInfo.CurrentCulture, 
                    FlowDirection.LeftToRight, 
                    new Typeface("Arial"), 
                    20, 
                    Brushes.Black), 
                    new Point(0, 150));
            }
        }
    }
    

    Markup:

    <Window x:Class="Adorners.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid x:Name="AdornedGrid">
            <TextBox x:Name="t" Width="200" Height="100" Background="Green"></TextBox>
        </Grid>
    </Window>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass '+' via the QueryString . some special character can be
I need to pass some parameters for a nested stored proc. Here is my
I know this could sound a little weird, but I need to pass some
I am doing a multi-threaded application in C# and need to pass some parameters
So I have a situation where I need to pass some parameters on url.
I have a java application I need to pass some info to a C++
I was using an mxml class but since i need to pass some properties
I'm writing a web application where I need to pass some user data to
I need to find a way to pass some strings to my word 2003
I am writing some and I need to pass a complicated data structure 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.