This question is locked. New answers and comments are not allowed.
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.
(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.