Wednesday, August 15, 2012

Show Popup at a clicked location

Show Popup at a clicked location

Hello All,

I have a requirement where i need to show a pop on a button click inside a grid of a XAML file in a silver light application. In my grid i have multiple rows from database. So when i click on this button which will be there in each row, the popup should appear near the clicked location.

I have tried getting 

GeneralTransform transform = base.TransformToVisual(button);
Point point = transform.Transform(new Point(0, 0));

popup.show(point.x, point.y)

But it seems to be not working, the pop up comes at the same place all the time...............

Any one have other ideas...........

Answers & Comments...

Answer: 1

You need to use mouseleftbuttondown event handler instead of click and use the below code to position the popup

var point = e.GetPosition(App.Current.RootVisual);              Popup p = new Popup();              p.HorizontalOffset = point.X;              p.VerticalOffset = point.Y;  

Please note it will show the popup at the exact position where mouse was clicked.

Let me know if it works.

Cheers!

Vinod

http://www.exploresilverlight.com

by :

Answer: 2

Not at all working brother :(

by :

Answer: 3

For which control should i have this mouseleftbuttondown event handler,

is  it for

i. the button inside the grid. (when i attach the event for this control, the event does not seem to fire)

ii. or the grid itself

by :

Answer: 4

Hi,

Please try to refer to the ManipulationCompleted event:

ManipulationCompleted="ManipulationCompleted_1"  

        private void ManipulationCompleted_1(object sender, ManipulationCompletedEventArgs e)          {              MessageBox.Show(e.ManipulationOrigin.X.ToString() + " " + e.ManipulationOrigin.Y.ToString());          }

Hope helpful

by :

Answer: 5

Can you put the whole xaml here..and let me see your xaml ??

by :




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog