Programmatically show/hide a RadSplitContainer floating

1 Answer 215 Views
Docking
Luigi
Top achievements
Rank 3
Bronze
Iron
Iron
Luigi asked on 30 Dec 2021, 09:22 AM | edited on 30 Dec 2021, 09:24 AM

Hi

I created a main window with RadDocking with DocumentHost and some RadSplitContainer.
Now with a user interaction I show a modeless window: I'd like to give the user the ability to dock this window in main window as docking part.
In the first look example of RadDocking there is a initial floating RadSplitContainer, but I would that my floating part only show after the user click a button and it was initially hidden.

Also, if I close the initially visible flaoting part, then I can't reopen it.

This is the flow of visibility:
1) Launch the application: floating window is not visible
2) Click on some button: floating window is now visible
3) User can dock the floating window on mainwindow docking

This is the RadDocking piece of xaml:

<t:RadDocking x:Name="radDocking1"
                            RetainPaneSizeMode="DockingAndFloating"
                            CanAutoHideAreaExceedScreen="True"
                            Grid.Row="1" Margin="0 0 0 10"                            
                            BorderThickness="0"
							CloseButtonPosition="InPane"
                            Padding="0"
						  PaneStateChange="radDocking1_PaneStateChange">
<t:RadDocking.DocumentHost>
<some code>
</t:RadDocking.DocumentHost>
<t:RadSplitContainer>
<some code>
</t:RadSplitContainer>
<t:RadSplitContainer>
<some code>
</t:RadSplitContainer>
<some code>
<t:RadSplitContainer>
</t:RadSplitContainer>
<t:RadSplitContainer Name="ImpulsiFloatContainer" 
						InitialPosition="FloatingDockable"
						 t:DockingPanel.InitialSize="900,1340"									 
						 Visibility="{Binding ImpulsiViewVisible, Converter={StaticResource BoolToVis}}">
					<t:RadPaneGroup >
						<t:RadPane  Header="{DynamicResource ResourceKey={x:Static r:ResourcesKeys.ImpulsiViewHeader}}">
							<local:ImpulsiViewControl />
						</t:RadPane>
					</t:RadPaneGroup>
				</t:RadSplitContainer>
			</t:RadDocking>

Thank you

Luigi

 

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 03 Jan 2022, 02:14 PM

Hello Luigi,

Generally, by setting the InitialPosition property to either FloatingOnly or FloatingDockable as a value, on an element, will initially host it inside a ToolWindow, which is a container that holds all elements that are in a floating state. With that said, to achieve the wanted result, you could subscribe to the ToolWindowCreated event of the RadDocking control. In it, the e.CreateElement property will be the newly created ToolWindow (ImpulsiFloatContainer RadSplitContainer) control. You could keep a reference to it inside the code-behind of the view, and via a button Click event, to change its Visibility property to Visible.

The following code snippets show the abovementioned logic's implementation:

<telerik:RadDocking ToolWindowCreated="RadDocking_ToolWindowCreated"/>
public partial class MainWindow : Window
{
    private ToolWindow impulsiFloatContainer;

    public MainWindow()
    {
        InitializeComponent();
    }

    private void RadButton_Click(object sender, RoutedEventArgs e)
    {
        this.impulsiFloatContainer.Visibility = Visibility.Visible;
    }

    private void RadDocking_ToolWindowCreated(object sender, Telerik.Windows.Controls.Docking.ElementCreatedEventArgs e)
    {
        this.impulsiFloatContainer = (ToolWindow)e.CreatedElement;
        this.impulsiFloatContainer.Visibility = Visibility.Collapsed;
    }
}

I have attached a sample project for you to test, so, could you give it a try?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Luigi
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 14 Dec 2022, 10:55 AM

Thank you Stenly
Originally, I gave up to that feature. But now I found myself in the same situation with a different window and I follow your hint.
My solution is little different I used a binding:


private void RadDocking_ToolWindowCreated(object sender, Telerik.Windows.Controls.Docking.ElementCreatedEventArgs e)
    {
        this.impulsiFloatContainer = (ToolWindow)e.CreatedElement;
		this.impulsiFloatContainert.SetBinding(VisibilityProperty, new Binding()
				{
					Path = new PropertyPath("booleanviewmodelProperty"),
					Mode = BindingMode.TwoWay,
					Converter = new Converter.BooleanToVisibility()
				}) ;
    }
}

Luigi
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 14 Dec 2022, 11:27 AM

There is another question about the floating dockable frame, it is about the initial size and position of window. It is always in the upper left corner and large about 220x300 px. Also in your sample, though you set telerik:DockingPanel.InitialSize="900,1340".
Thank you again

Luigi

Stenly
Telerik team
commented on 19 Dec 2022, 09:40 AM

Hello Luigi,

Regarding the size of the created ToolWindow, instead of setting the DockingPane.InitialSize, you could directly modify its Width and Height properties.

this.impulsiFloatContainer = (ToolWindow)e.CreatedElement;
this.impulsiFloatContainer.Width = 900;
this.impulsiFloatContainer.Height = 1340;

About the location, you could set the Top and Left properties of the created ToolWindow element.

this.impulsiFloatContainer = (ToolWindow)e.CreatedElement;
this.impulsiFloatContainer.Top = 300;
this.impulsiFloatContainer.Left = 600;

I hope the provided information will be of help to you.

Tags
Docking
Asked by
Luigi
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or