You can right click on a tab in the XamDockManager and toggle between a tabbed document and a floating window. How can I do this in C# so I can execute this behavior from a button click.
These actions are associated with content pane commands so you can use them, for example :
ContentPane cp = new ContentPane();
cp.ExecuteCommand(ContentPaneCommands.ChangeToDocument);
ContentPaneCommands.ChangeToFloatingOnly works to float the window but the window always comes up in the small possible size. I have tried
XamDockManager.SetFloatingLocation(pane, new Point(20, 20));
XamDockManager.SetFloatingSize(pane, new Size(300, 200));
both before and after the ExecuteCommand but the window doesn't size. How can i set the size of the floated tab window?
I believe these properies are intended for the SplitPane panes. What you can do is to handle the ToolWindowOpening event and use them to set the size/location on the newly loaded split pane :
private void xamDockManager1_ToolWindowLoaded(object sender, Infragistics.Windows.DockManager.Events.PaneToolWindowEventArgs e)
{
XamDockManager.SetFloatingSize(e.Window.Pane
, new Size(700, 700));
XamDockManager.SetFloatingLocation(e.Window.Pane, new Point(20, 20));
}
I thought I had the infragistics controls down but this floating window has me stumped. I now can click a button in the tab header and successfully float the window. Now I need to add a button to the header in the floating window to unfloat it. I can change the header in the docked windows but not the floating window. How do I add a button to the header of the floating window.
In order to retemplate the PaneToolWindow ( the floating window) you would have to set its UseOSNonClientArea to false. Yu can do this in the ToolWindowLoaded event of the XamDockManager :
private
void xamDockManager1_ToolWindowLoaded(object sender,PaneToolWindowEventArgs e){
window.UseOSNonClientArea =
false;
Then you can apply a template to the window (ContentTemplate property) and put the button you want to toggle the pane's state there. However, please note that the content of the PaneToolWindow is a SplitPane, as you can dock multiple panes in one PaneToolWindow. In order to toggle the state, you would either have to set the CommandTarget property if you are using a command or find the content pane in the SplitPane's Panes collection and toggle its state in the Click event. Here is how you can do this with a command :
<
DataTemplate x:Key="toolWindowTemplate">
<DockPanel>
<Button DockPanel.Dock="Top" Width="20" Height="20" Content="X"
CommandTarget="{Binding Panes[0]}"
Command="{x:Static igDock:ContentPaneCommands.ToggleDockedState}"/>
<ContentPresenter DockPanel.Dock="Top" Content="{Binding}"/>
</DockPanel>
</DataTemplate>
I added the DataTemplate (I set the background to red to easily see it) to the ToolWindow (I set in OnToolWindowLoaded) ContentTemplate. All it did was change the top line of the content in the tool window but didnt change the tool window header. The tool window doesnt have a header template, the split window doesnt have a header template, and I changed the header template of the content pane, no luck.
Where is the world is the header content for the tool window?
I gave up trying to set a template and found the original default ToolWindowPane style. That contained the pane header. From there I was able to successfully modify the the header area.
I did figure out how to do this and am adding just for reference. Place the number of the tab in the tag field of the content pane then...
contentPane.ExecuteCommand(ContentPaneCommands.ChangeToDocument);
var sortList = new SortedList<int, ContentPane>();
foreach(var item in ProgramTabGroupPane.Items)
var pane = item as ContentPane;
if (pane == null) continue;
sortList.Add(int.Parse((string)pane.Tag), pane);
ProgramTabGroupPane.Items.Clear();
foreach(var pane in sortList.Values)
ProgramTabGroupPane.Items.Add(pane);
ProgramTabGroupPane.SelectedIndex = int.Parse((string)contentPane.Tag) - 1;
rkcarlin said:Is it possible to reposition the returned tab back to its original position?
No, the information about where the document was is not currently preserved. Instead when the pane is readded to the document area it is inserted as the first tab in the tabgroup containing the current active document. This was done to mimic the behavior of documents in VS 2008 and prior. You may want to submit a suggestion for preserving the document location.
If you use the ToggleDockedState command, the content pane will return to its old docked position.
Found one more problem. After floating the content pane in the ToolWindowPane, I return it with contentPane.ExecuteCommand(ContentPaneCommands.ChangeToDocument). However, it always returns to the first Tab. If someone floats tab 8 I would like to return it to tab 8. This behavior also happens when using right click to float and return the window. I tried setting the contentPane.TabIndex but t doesnt seem to do anything.
Is it possible to reposition the returned tab back to its original position?