C# WPF DataGrid outside Window
Question
I am building an application that requires a DataGrid
that can be hidden. I have tried wrapping it in an Expander
but it isn't exactly ideal. Ideally what I would like is the ability to have the DataGrid
"floating" outside the main window without affecting the other controls and just having a button to hide and show it when needed.
Is this at all possible?
Thanks for your time.
Solution
You could put it in a Popup
and change its IsOpen state to hide or show it. Though keep in mind that the Popup won't move around with the window.
OTHER TIPS
You will have to put it on a form to make it float. The new form can be a child of the main form opened as non-modal.
<ToggleButton Name="ShowHideGrid" Content="Show/Hide Grid"/>
<Popup IsOpen="{Binding ElementName=ShowHideGrid, Path=IsChecked}">
<!-- Grid goes here -->
</Popup>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow