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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:37:38+00:00 2026-05-20T04:37:38+00:00

I have a simple UserControl as below – that I place in a Canvas.

  • 0

I have a simple UserControl as below – that I place in a Canvas. I move it using Multi-touch and I want to be able to read its new X,Y postion using procedural C# code. Ideally I would like to have X and Y as two properties or as a Point (X,Y).

<UserControl x:Class="TouchControlLibrary.myControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="64" d:DesignWidth="104">
    <Border Name="ControlBorder" BorderThickness="1" BorderBrush="Black">
        <DockPanel Margin="1" Height="60 " Width="100">
            <StackPanel  DockPanel.Dock="Left" Background="Gray"  Width="20" >
                <Button Background="#FFDEDE53" Padding="0">In</Button>
            </StackPanel>
            <StackPanel  DockPanel.Dock="Right" Background="Gray"  Width="20" >
                <Button Background="#FFE8B48F" Padding="0">Out</Button>
            </StackPanel>
        </DockPanel>  
    </Border>
</UserControl>

I expected to create an attached property for each of ‘X’ and ‘Y’ and fill them from Canvas.Left and Canvas.Top, using binding or some form of attached property or ???. I have spent quite some time searching for a solution, but everything I find seems to be ‘not quite what is needed’.

  • 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-20T04:37:39+00:00Added an answer on May 20, 2026 at 4:37 am

    You can use two properties like this in your userControl,

        public double Top
        {
            get
            {
                if (double.IsNaN(Canvas.GetTop(this)))
                {
                    return (double)0;
                }
                return Canvas.GetTop(this);
            }
    
            set
            {
                Canvas.SetTop(this, value);
            }
        }
    

    The check for “NotANumber” is not realy necessary, but I use it to prevent errors.

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

Sidebar

Related Questions

I have a very simple UserControl as shown below. I'm trying to get the
I have a really simple WPF UserControl: <UserControl x:Class=dr.SitecoreCompare.WPF.ConnectionEntry xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml x:Name=connEntry BorderBrush=Navy BorderThickness=1
Ok, i have simple scenario: have two pages: login and welcome pages. im using
Should simple JavaBeans that have only simple getters and setters be unit tested?? What
I have a simple webform that will allow unauthenticated users to input their information,
I have a simple 2-column layout with a footer that clears both the right
I have a very simple WPF user control that is mixed in with a
I have a very weird issue. I have a UserControl that has some controls
I have a simple form on a view page, implemented as a user control,
I have simple regex \.*\ for me its says select everything between and ,

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.