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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:28:11+00:00 2026-05-20T00:28:11+00:00

I made an usercontrol and it works great, but when I put two instances

  • 0

I made an usercontrol and it works great, but when I put two instances of this control to one window, only the last of them works. I tried to find solution and I realized, that dependency properties are shared, but I dont know how to get it work.

Here is my dependency property:

    public double AnimatingVerticalOffset
    {
        get { return (double)GetValue(AnimatingVerticalOffsetProperty); }
        set { SetValue(AnimatingVerticalOffsetProperty, value); }
    }

    public static readonly DependencyProperty AnimatingVerticalOffsetProperty;

    static ListChooser()
    {
        ListChooser.AnimatingVerticalOffsetProperty =
                   DependencyProperty.Register("AnimatingVerticalOffset", typeof(double), typeof(ListChooser), new UIPropertyMetadata(OnAnimationVerticalOffsetChanged));
    }
  • 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-20T00:28:12+00:00Added an answer on May 20, 2026 at 12:28 am

    The dependency property itself must be static with no ties to one single instance. And that applies for its callbacks too (OnAnimationVerticalOffsetChanged in your case) – these must be static methods (don’t worry, the object instance is passed via its parameter, you just have to do some type casting to ensure the object is the type you are working with).

    You should use static initializer to initialize DP, the method you used (initializing in constructor) works, but the DP will overwrite for each instance.

    See this question for deeper explanation.

    EDIT:

    Corrected code:

    public double AnimatingVerticalOffset
    {
        get { return (double)GetValue(AnimatingVerticalOffsetProperty); }
        set { SetValue(AnimatingVerticalOffsetProperty, value); }
    }
    
    public static readonly DependencyProperty AnimatingVerticalOffsetProperty =
                   DependencyProperty.Register("AnimatingVerticalOffset", typeof(double), typeof(ListChooser), new UIPropertyMetadata(OnAnimationVerticalOffsetChanged));
    
    static ListChooser()
    {
    }
    

    If the callback is not static, you will get compile error (=> you have to make it static).

    EDIT:

    Remember, the DP definition is static, not the property’s value itself! DPs work exactly just like any other property, it just has some extra features: value inhertiance, bidnings, animation…

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

Sidebar

Related Questions

I have a form and two custom UserControl that I made myself. one control
I have made some progress with the DataList and UserControl this morning but I
I made a UserControl that has a Property of type RotateFlipType , this control
i made an easy web user control by reading Scottgu articles BUT; my user
Made this nice little loop for hiding and showing div's, works as a charm
I'm having an issue where I have made a user control with two content
This may be a long shot, but I'm using ComponentOne's Spellchecker control for Silverlight.
I've made a simple custom control with ClickEvent: ImageButton.xaml: <UserControl x:Name=ImgButton x:Class=WpfApplication1.ImageButton xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have made a control library and two user controls. userControl_1 contains a Panel
This is a bit of a strange one, but I've been struggling for a

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.