0

I am trying to make a WPF window with some comboboxs and menus.

After any comboxbox or the menu is opened or clicked , when I try to close/minimize/maximize using the icons built-in with the WPF window itself , it takes me two clicks , the first one is to close the menu/combox and the second click is to close/minimize/maximize.

I want to overcome this behavior , which means to close/minimize/maximize the WPF window by one single click regardless any open menus or comboboxes. Any help please?

<Window x:Class="ConnectionTable.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:ConnectionTable"
    mc:Ignorable="d"
    Closing="Window_Closing"
    Title="GUI Console" WindowStartupLocation="CenterScreen" WindowState="Maximized">
<Grid HorizontalAlignment="Stretch" Height="auto" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="auto">
    <Button x:Name="b1" Content="Connect" HorizontalAlignment="Right" Margin="0,0,56.333,23.333"  VerticalAlignment="Bottom" Width="140" Height="52" Click="Button_Click"/>
    <Button x:Name="b2" Content="Filter" HorizontalAlignment="Right"  Margin="0,0,240.333,23.333"  VerticalAlignment="Bottom" Width="140" Height="52" Click="Filter_Click" IsEnabled="False" />
    <Button x:Name="b3" Content="Mail" HorizontalAlignment="Right"  Margin="0,0,400.333,23.333"  VerticalAlignment="Bottom" Width="140" Height="52" Click="SendMail" IsEnabled="False"/>
    <DataGrid x:Name="dg" IsReadOnly="True" Margin="50,47,56.333,114.333" Background="#FFC9DEF5" />
    <ComboBox x:Name="cbox" HorizontalAlignment="Left" Margin="39,550,0,22.333" Width="150" Height="30" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
    </ComboBox>
    <ComboBox x:Name="cbox2" HorizontalAlignment="Left" Margin="200,550,0,22.333" Width="150" Height="30">
        <ScrollViewer VerticalScrollBarVisibility="Auto" Height="70" CanContentScroll="True" Width="150" >
            <StackPanel x:Name="spanel2" CanVerticallyScroll="True"/>
        </ScrollViewer>
    </ComboBox>
    <Menu HorizontalAlignment="Stretch" VerticalAlignment="Top">
        <MenuItem Header="_File">
            <MenuItem Command="Save" HorizontalAlignment="Left" Width="150"/>
            <Separator HorizontalAlignment="Left" Width="150"/>
            <MenuItem Command="Close" HorizontalAlignment="Left" Width="150"/>
        </MenuItem>
        <MenuItem Header="_Edit">
            <MenuItem Command="Cut" />
            <Separator HorizontalAlignment="Left" Width="140"/>
            <MenuItem Command="Copy" />
            <Separator HorizontalAlignment="Left" Width="140"/>
            <MenuItem Command="Paste" />
        </MenuItem>
    </Menu>
</Grid>

Boudy
  • 1
  • 2
  • Please provide your code and explain what you have attempted – He Hui Apr 25 '17 at 08:58
  • Possible partial duplicate of http://stackoverflow.com/questions/5752067/releasing-mouse-capture-and-letting-mouse-click-pass-through. – Anton Tykhyy Apr 25 '17 at 09:25
  • Check this: http://stackoverflow.com/questions/40068021/wpf-combobox-dropdown-is-preventing-clicking-other-controls – mm8 Apr 25 '17 at 11:57

0 Answers0