I need to create a custom dropdown that has a button to open it, and a panel to show something, and i want to get it to close when click on outside of it, what kind of panel should i use?
I tried popupmenu but I couldn’t make it close after lostfocus, and tried contextmenu but it get close on click on it’s inner item.
Any suggestion whould be appreciated.
I tried something like this:
<Button x:Name="toggleButton"
ContextMenuService.Placement="Top" Click="ToggleButton_Click"
Margin="0" Content="+">
<Button.ContextMenu>
<ContextMenu Width="200"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" >
<StackPanel>
<DataGrid >
<DataGrid.Columns>
<DataGridTextColumn/>
<DataGridTextColumn/>
</DataGrid.Columns>
</DataGrid>
<TextBlock Text="sadfasdfas" />
<TextBox Text="" Width="100"/>
</StackPanel>
</ContextMenu>
</Button.ContextMenu>
</Button>
finally i created what i needed after 2 days!!,and i really coulden’t find a better solution,i had to put two button,on for showing the popup and another for closing the popup!
in xaml
in codebehind