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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:51:19+00:00 2026-05-24T12:51:19+00:00

I am trying to cause a Grid (and all the controls on it) to

  • 0

I am trying to cause a Grid (and all the controls on it) to shake in my WP7 app. Seems the best way to offset the grid is using the Margin property, but there is no ThicknessAnimationUsingKeyFrames supported in WP7 so I can’t do it directly.

Instead, I have created a custom control:

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;

namespace MyNamespace
{
  // Grid which has an OriginOffset property that is tied to the margin,
  // and thus can be animated.

  public class OffsettableGrid : Grid
  {
    public OffsettableGrid()
    {
    }

    public static readonly DependencyProperty OriginOffsetProperty = 
        DependencyProperty.Register(
        "OriginOffset", typeof(Point), typeof(OffsettableGrid), null);

    public Point OriginOffset
    {
      get
      {
        return new Point(Margin.Left, Margin.Top);
      }
      set
      {
        Margin = new Thickness(value.X, value.Y,
          Margin.Right, Margin.Bottom);
      }
    }
  }
}

and then in xaml I declare a storyboard as follows:

<Storyboard x:Name="m_shakeStoryboard" 
            RepeatBehavior="5x" 
            AutoReverse="False" 
            SpeedRatio="5">

    <PointAnimationUsingKeyFrames 
        BeginTime="00:00:00"
        Storyboard.TargetName="m_chooseAnswerGrid"
        Storyboard.TargetProperty="(OffsettableGrid.OriginOffset)">

        <EasingPointKeyFrame KeyTime="00:00:00"    Value="0,0"/>
        <EasingPointKeyFrame KeyTime="00:00:00.2"  Value="-10,0"/>
        <EasingPointKeyFrame KeyTime="00:00:00.4"  Value="10,0"/>
        <EasingPointKeyFrame KeyTime="00:00:00.6"  Value="0,0"/>
    </PointAnimationUsingKeyFrames>

</Storyboard>

and then of course I declare my grid using .

But when I go to start the storyboard:

m_shakeStoryboard.Begin();

my OriginOffset property never gets invoked. I put a breakpoint at “Margin = new Thickness(value.X, value.Y,” but it never gets hit. What am I doing wrong?

In the editor, whenever I change OriginOffset, the margins change as well as expected.

Any help much appreciated!
Thanks

  • 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-24T12:51:20+00:00Added an answer on May 24, 2026 at 12:51 pm

    Your dependency property is not well defined. You should use SetValue and GetValue:

    public Point OriginOffset
    {
       get
       {
           return (Point)GetValue(OriginOffsetProperty);
       }
       set
       {
           SetValue(OriginOffsetProperty, value);
       }
    }
    

    Then add a callback to the PropertyMetadata of the dependency property, to set the margin:

    public static readonly DependencyProperty OriginOffsetProperty = 
        DependencyProperty.Register(
            "OriginOffset", 
            typeof(Point), 
            typeof(OffsettableGrid), 
            new PropertyMetadata(new PropertyChangedCallback(OnOriginOffsetChanged)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we are trying to implement an application using the Service Layer Pattern cause our
I'm trying to visualize some data I have stored on a regular grid using
I'm trying to calculate all the possible values of a grid size (x by
I'm new to jQuery, and I'm trying to cause another identical dropdown menu to
I am trying to find the cause of a crash in my Java application.
I'm trying to find the root cause of the error message when viewing my
I'm trying to rephrase my question, cause my last one wasn't clear to everyone.
I am trying to solve GameOfLife in Scala where I have an infinte grid.
I am trying to implement jqgrid v3.7 in my webapplication created using cakephp v1.3.
I'm trying to use Telerik MVC Grid for an application which requires lots of

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.