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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:58:30+00:00 2026-05-13T01:58:30+00:00

Is there a way to bind a value to the absolute position of a

  • 0

Is there a way to bind a value to the absolute position of a control using XAML?

I have a Line element that I would like to be drawn between two Buttons in my application. I was thinking that binding the starting point of the Line to the position of the Button would be the easiest way to make this happen, using RelativeSource somehow.

  • 1 1 Answer
  • 1 View
  • 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-13T01:58:30+00:00Added an answer on May 13, 2026 at 1:58 am

    It seems you want something like this:

    <UserControl x:Class="PracticeSample.MyButton"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid>
        <Button x:Name="button" Content="Add" HorizontalAlignment="Center" VerticalAlignment="Top"/>
        <Line Stroke="Black" X1="0" Y1="0" HorizontalAlignment="Center" X2="{Binding ElementName=button, Path=ActualWidth}" Y2="{Binding ElementName=button, Path=ActualHeight}"/>
    </Grid>
    

    use this MyButton in your pages in place of Button,

    Edit:
    if you want to draw line between two controls
    don’t use above code sample but try this directly in your page:

    <Canvas HorizontalAlignment="Left" Margin="10">
        <Button x:Name="button2" Content="Add" Canvas.Left="10" Canvas.Top="5"/>
        <Button Name="button" Content="Refresh Control" Canvas.Left="100" Canvas.Top="50"/>
        <Line Stroke="Black" X1="{Binding Path=(Canvas.Left),ElementName=button2}" Y1="{Binding Path=(Canvas.Top), ElementName=button2}" X2="{Binding (Canvas.Left), ElementName=button}" Y2="{Binding (Canvas.Top), ElementName=button}"/>
    </Canvas>
    

    Hope this helps!

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

Sidebar

Related Questions

I'd like to know if there's a way to bind the returned value of
Is there any way bind textboxes to the row of a dataset that is
Is there any way to bind two windows from seprate processes together using Python/Pygame?
I've a WPF4 Application. There I bind an UI Control to a DateTimeOffSet value.
Is there a way to have element to element binding in Silverlight templated controls?
Is there any good way to bind a property to a const value in
Using SilverLight, one can bind the value of a control to a property from
I have a custom data-bind like this : ko.bindingHandlers.calendar = { init: function(element, valueAccessor)
Is there a clean way to bind only the initial value of an observable
JBoss 7.1.1.Final question: Is there any way that jboss.bind.address.management and jboss.bind.address.unsecure can be set

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.