丢失鼠标捕获时关闭弹出窗口

时间:2019-12-07 13:08:01

标签: wpf popup

我尝试使用ComboBox之类的弹出菜单创建自定义控件。 我的问题是当鼠标失去焦点并且CaptureMouse位于弹出窗口中的按钮上时。

  1. 打开弹出窗口
  2. 按下按钮。
  3. 按Windows键。
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.10.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.10.2/umd/react-dom.production.min.js"></script>
<Grid Background="DarkGray">
<Border BorderBrush="Gray" BorderThickness="1">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <Border Grid.Column="0">
            <Grid>
                <TextBlock Text=""/>
            </Grid>
        </Border>
        <ToggleButton Grid.Column="1" IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"/>
    </Grid>
</Border>

<Popup x:Name="PART_Popup" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom">
    <Button Content="Test"/>
</Popup>
</Grid>

默认的ComboBox本身称为额外的Lost。我不明白为什么。

0 个答案:

没有答案