Adding a Popup from a cell click event

4 posts, 1 answers
  1. Marshall
    Marshall avatar
    4 posts
    Member since:
    Jul 2011

    Posted 22 Feb 2012 Link to this post

    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.
  2. Answer
    Tyree
    Tyree avatar
    105 posts
    Member since:
    Dec 2006

    Posted 24 Feb 2012 Link to this post

    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.
  3. Marshall
    Marshall avatar
    4 posts
    Member since:
    Jul 2011

    Posted 24 Feb 2012 Link to this post

    Thanks. This looks great.
  4. Tyree
    Tyree avatar
    105 posts
    Member since:
    Dec 2006

    Posted 24 Feb 2012 Link to this post

    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.
Back to Top