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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:19:01+00:00 2026-06-11T07:19:01+00:00

I use this article to create some runtime moveble control In WPF Porject everything

  • 0

I use this article to create some runtime moveble control In WPF Porject everything works fine, but it persistently don’t want to work when I host my WPF control into WinForm. Somebody know where can be problem ?

C# part for movable control

using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace EvTest.Resource
{

public class MoveThumb : Thumb
{
    public MoveThumb()
    {
        DragDelta += new DragDeltaEventHandler(this.MoveThumb_DragDelta);
    }

    private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
    {
        Control designerItem = this.DataContext as Control;


            double left = Canvas.GetLeft(designerItem);
            double top = Canvas.GetTop(designerItem);

            Canvas.SetLeft(designerItem, left + e.HorizontalChange);
            Canvas.SetTop(designerItem, top + e.VerticalChange);

    }
}
}

Xaml control part :

<UserControl x:Class="EvTest.Control"
         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"
         xmlns:s="clr-namespace:EvTest.Resource"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>

        <!-- MoveThumb Template -->
        <ControlTemplate x:Key="MoveThumbTemplate" TargetType="{x:Type s:MoveThumb}">
            <Rectangle Fill="Transparent"/>
        </ControlTemplate>

        <!-- ResizeDecorator Template -->


        <!-- Designer Item Template-->
        <ControlTemplate x:Key="DesignerItemTemplate" TargetType="ContentControl">
            <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                <s:MoveThumb Template="{StaticResource MoveThumbTemplate}"/>
                <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/>
            </Grid>
        </ControlTemplate>

    </UserControl.Resources>

    <Canvas>
        <ContentControl Width="130"
                MinWidth="50"
                Height="130"
                MinHeight="50"
                Canvas.Top="149"
                Canvas.Left="158"
                Template="{StaticResource DesignerItemTemplate}">
            <Ellipse Fill="Red"
           IsHitTestVisible="False"/>
        </ContentControl>
        <ContentControl Width="130"
                MinWidth="50"
                Height="130"
                MinHeight="50"
                Canvas.Top="12"
                Canvas.Left="12"
                Template="{StaticResource DesignerItemTemplate}">
            <Path Fill="Blue"
        Data="M 0,5 5,0 10,5 5,10 Z"
        Stretch="Fill"
        IsHitTestVisible="False"/>
        </ContentControl>
    </Canvas>


</UserControl>
  • 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-06-11T07:19:02+00:00Added an answer on June 11, 2026 at 7:19 am

    I find problem. It must be like this :

    private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
    {
        ContentControl designerItem = this.DataContext as ContentControl;
    
    
            double left = Canvas.GetLeft(designerItem);
            double top = Canvas.GetTop(designerItem);
    
            Canvas.SetLeft(designerItem, left + e.HorizontalChange);
            Canvas.SetTop(designerItem, top + e.VerticalChange);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this function substr(tbarticles.articlebody,1,200) as description1 in a query but for some articles
I read this article on how to use keytool to generate CSRs for your
this article suggests you can use Color c = Color.decode(FF0096); however this understandably throws
I found this article who explain how to use cache items expiration to make
This article on MSDN states that you can use as many try catch blocks
According to this article , it says: Use a delegate in the following circumstances:
An user posts this article about how to use HttpResponse.Filter to compress large amounts
After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile
I'm trying to to use this class http://robbyonrails.com/articles/2005/05/11/parsing-a-rss-feed but am not sure where to
use this website a lot but first time posting. My program creates a number

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.