In the Xaml I am able to achieve removing all the headers on a page with the following code:
<Grid Name="mainGrid">
<Grid.Resources>
<Style x:Key="key1" TargetType="{x:Type igWPF:PaneHeaderPresenter}">
<Setter Property="MinHeight" Value="0"/>
<Setter Property="MaxHeight" Value="0"/>
</Style>
</Grid.Resources>
However I would like to do it programatically from the codebehind (possibly by binding the toggle to a checkbox) to allow users to decide whether or not they can see grid headers and move contentPanes within the XamDockManager
Thanks
(also, I posted the same question here: http://es.infragistics.com/community/forums/p/90496/447231.aspx#447231 without realizing that this section was a better place for it. Please feel free to lock/remove that one, thanks).
Hello Christian,
To hide and unhide the headers through code-behind, I handled the Checked and Unchecked events of the checkbox and then used Utilities.GetDescendantFromType to retrieve the PaneHeaderPresenter from each of the ContentPanes. Then, I just set the Min and Max height of these PaneHeaderPresenters to 0.
The Unchecked handler is very much the same, except the MaxHeight gets set to something other than 0 in that one.
To hide and unhide them through data binding to that checkbox, I wrote a Style that uses data triggers that target the checkbox’s IsChecked property. If it is true, it hides the header.
I have attached a sample demonstrating the above. Note that in the attached sample, the Style is commented out and it is using the event handler way of achieving this functionality.
Please let me know if you have any other questions or concerns.
Sincerely,AndrewDeveloper Support IInfragistics Inc.www.infragistics.com/support
Alright, I managed to open the sample code in notepad++ and it looks legit.
Only two things:
1) when I put my original xaml, it affected every single pane currently on the screen, and any subsiquent pane added to the screen. In the codebehind you provided, you have to explicitly list the pane names.. is there any way to say "for every datagrid inside of the <grid> tag, toggle headers?"
2) what about controlling the style of one view from another. Meaning, if I were to put that checkbox inside of a seperate ribbon.xaml, and then put the ribbon inside of mainxaml, how could I use the checkbox from the ribbon to control the grid headers of the main viewmodel?
Just checking in, do you have any other questions or concerns on this matter?
With regards to your first question, the way to get every pane on the screen is to use a nested foreach loop. The first one loops through each SplitPane in the DockManager.Panes collection and the second one loops through each ContentPane in the SplitPane.Panes collection. Then retrieve the PaneHeaderPresenter using the Utilities class and set the Min and Max height to your desired value.
Regarding your second question, if you are putting a button(for example) into a UserControl which holds a Ribbon and you want it to act on the Window you are putting it into, name the button when you put it in the UserControl. Then, when you put the UserControl into your MainWindow, name the UserControl as well.
In the code-behind, you will be able to access that button by calling UserControlName.ButtonName. Then assign it an event handler and use the techniques above.
Regarding your third question, if you want to disable the headers in another Window or panel, you can instantiate it and load it in your main window to get a reference to it. Then, you can get the DockManager that holds the panes, and disable the headers from there by doing the following:foreach(SplitPane CP in Window2Object.NameOfDockManagerInWindow2.Panes)
I have attached a sample application using Visual Studio 2010 to demonstrate.
Please let me know if you have any other questions or concerns on this matter.
Or what if I wanted to disable them for every single grid in my project, regardless of what screen/panel they are contained in?