开发者

How do I place a Popup in my DataGridTemplateColumn.CellEditingTemplate correctly?

开发者 https://www.devze.com 2023-03-09 13:24 出处:网络
I have the following XAML .. <DataGridTemplateColumn Header=\"Comparison key\"> <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&g开发者_运维百科t;
        <DataTemplate>
                <TextBlock Text="{Binding KeyStatusText}" Name="txtKeyStatus">
                </TextBlock>
        </DataTemplate>                                
    </DataGridTemplateColumn.CellTemplate>

I am trying to show a Popup when editing the cell, this works fine but the problem is that the Popup does not close when clicking outside of the DataGrid. If for example I move the Window the Popup remains open but does not move with the Window.

Can anybody help with a solution to this? Cheers.


Use a trigger which will set IsOpen property to False.


Set Popup.StaysOpen Property to False.

0

精彩评论

暂无评论...
验证码 换一张
取 消