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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:14:02+00:00 2026-06-11T13:14:02+00:00

I am using c#, Silverlight, WP7. I have a Pivot in my app, and

  • 0

I am using c#, Silverlight, WP7.

I have a Pivot in my app, and after each LoadedPivotItem event, I want to look at the UI tree to see where each item is located on the screen. Specifically, I am interested in the margin value, which is the x-offset from the left side of the screen.

Here is my code:

GeneralTransform gt = myUIElement.TransformToVisual(Application.Current.RootVisual);
double x = ((MatrixTransform)gt).Matrix.OffsetX;
Debug.WriteLine("Margin = {0}, UIElement = {1}", x, myUIElement);

When the application launches, this code is executed and an example of the printout is:

Margin = 12, UIElement = System.Windows.Controls.TextBlock

The problem is that once I swipe (a LoadedPivotItem event fires) and move to the pivot on the right, the margins become negative numbers. Example:

Margin = -468, UIElement = System.Windows.Controls.TextBlock

The weird thing is, even if I swipe back to the first Pivot, the values on the margins change to:

Margin = 492, UIElement = System.Windows.Controls.TextBlock

And if I keep swiping in one direction and end up back at the first Pivot, the values on the margins become:

Margin = -468, UIElement = System.Windows.Controls.TextBlock

I realize that these numbers are all offset by the screen size of 480, but it doesn’t seem consistent to me and I’d like to not deal with adjusting by the screen size.

Any suggestions as to why this is happening and how to fix it?
Thanks in advance.

  • 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-11T13:14:03+00:00Added an answer on June 11, 2026 at 1:14 pm

    I’ve figured out the easiest solution to this problem, and that is to %mod the x-offset with the screen-width to get the actual margins. Here I assume the screen-width is 480.

    double x = ((MatrixTransform)gt).Matrix.OffsetX
    if (x < 0)
    {
        // modding a negative number is equal to the negative modding of the positive number
        x = 480 + (x % 480);
    }
    else
    {
        x = x % 480;
    } 
    

    After pivoting left and right many times, I think I’ve figured out what is going on. The UIElements are going through positive and negative translations depending on which way you swipe, but swiping left and swiping right don’t cancel each other out since the (0,0) location of RootVisual changes with respect to the UIElement.

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

Sidebar

Related Questions

I writing wp7 silverlight app. I have a listbox with items. I want each
I have a several MenuItem's inside a ContextMenu in my wp7 app using silverlight.
I'm using Reactive Extensions for easy event handling in my ViewModels (Silverlight and/or Wp7
Using Silverlight 4. I have two visual states for my control. I want to
I am developing a music player in wp7 using silverlight.My end users don't have
i'm building a wp7 application for a game using silverlight & XNA i have
I am using C#, Silverlight, WP7. I have been going over Metro Grid Helper
Using Silverlight 3 with RIA: What's the difference between the LoadOperation.Completed event and using
I am using silverlight 4. I have a scenario where i need to compare
I'm using Silverlight Beta 4 for a LOB application. After finding out today that

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.