How to place popup in my DataGridTemplateColumn.CellEditingTemplate?

I have the following XAML ..

<DataGridTemplateColumn Header="Comparison key">
    <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
            <Grid DataContext="{Binding Columns}">
                <Popup x:Name="popKeyComparison" 
                                Placement="Bottom" 
                                IsOpen="True"
                                Width="200" Height="100">
                    <StackPanel Orientation="Vertical" Background="Gray" >
                        <TextBlock Text="{Binding Name}"></TextBlock>
                        <Button>
                            <TextBlock>Somethingn here</TextBlock>
                        </Button>
                    </StackPanel>
                </Popup>
            </Grid>
        </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
                <TextBlock Text="{Binding KeyStatusText}" Name="txtKeyStatus">
                </TextBlock>
        </DataTemplate>                                
    </DataGridTemplateColumn.CellTemplate>

I'm trying to show Popup when editing a cell, this works great, but the problem is that Popup doesn't close when I click outside the DataGrid. If, for example, I move the window, the popup remains open, but does not move with the window.

Can anyone help with a solution to this? Greetings.

+3
source share
2 answers

Use a trigger that sets the IsOpen property to False.

0
source

Set the Popup.StaysOpen Property False.

0
source

All Articles