This is a migrated thread and some comments may be shown as answers.

Adding a Popup from a cell click event

3 Answers 178 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marshall
Top achievements
Rank 1
Marshall asked on 22 Feb 2012, 11:18 PM
Hello, I have been trying to successfully popup (Popup) a dialog relative to the clicked cell, and so far I can get the popup to display (relative to the whole app using LayoutRoot....Add()) but what I really want is to inject it at run time but I can not figure out how to get the correct object to eventually call Children.Add() with. 
(I can get the mouse click location no problem. )

Here is the event handler:
void FlagCallClick_event(object sender, EventArgs e)
        {
            var local = sender;
            var my_e = e;
            var p = new Popup();

            p.DataContext = ((sender as FrameworkElement).Parent as
                      FrameworkElement).DataContext;
           p.VerticalOffset = 25; // this will offset us slightly from the 
            // parent
            p.HorizontalOffset = 0;
            p.IsOpen = true;
            // this is where we add the popup to a Grid we can position 
            // against
            ((sender as FrameworkElement).Parent as Grid).Children.Add(p); //THIS FAILS, sender is not type Grid

            p.Child = new Border()
            {
                Child = new TextBlock() { Text = "Hello, World!" },
                Background = new SolidColorBrush(Colors.Cyan)
            }; 
        }

...
<telerik:GridViewColumn.CellTemplate>
                   <DataTemplate>
                            <StackPanel ToolTipService.ToolTip="Tool Tip" MouseLeftButtonUp="FlagCallClick_event" 
                                                    HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" >
                                        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                                <Image Width="16" Height="16" Source="{Binding [Flag],Converter={StaticResource FlagToImageConverterFunc}}" 
                                                       HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                                                </Image>
                                        </StackPanel>
                               </StackPanel>
                      </DataTemplate>
</telerik:GridViewColumn.CellTemplate>
............

thank you for your help.

3 Answers, 1 is accepted

Sort by
0
Accepted
Tyree
Top achievements
Rank 2
answered on 24 Feb 2012, 02:42 PM
I have a control I wrote to popup when a cell is hovered or clicked, or in my case goes into edit.

http://autoexpandover.codeplex.com/

Attached is a screenshot of a popup, in this example I clicked in the Volume column (which showed 100) and it popped up, the popup has another grid in it.
0
Marshall
Top achievements
Rank 1
answered on 24 Feb 2012, 05:57 PM
Thanks. This looks great.
0
Tyree
Top achievements
Rank 2
answered on 24 Feb 2012, 06:44 PM
Its lacking any samples but drop a message on the discussion board on codeplex and I can help you get it working in your app.
Tags
GridView
Asked by
Marshall
Top achievements
Rank 1
Answers by
Tyree
Top achievements
Rank 2
Marshall
Top achievements
Rank 1
Share this question
or