This is a migrated thread and some comments may be shown as answers.

RadPane width and height to be dynamic

3 Answers 377 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Gerard
Top achievements
Rank 1
Gerard asked on 10 Jan 2017, 03:45 PM

I have a Floating Radpane (2.gif) and I want this to fit the content inside. Is it possible to make it behave like the 1.gif grid?

What I want is for the width and height to be dynamic depending on the content.

The RadPane structure is as follows:

<telerik:RadDocking x:Name="RadDockingFloating">
    <telerik:RadSplitContainer x:Name="RadSplitContainer" Visibility="Collapsed" telerik:RadDocking.FloatingLocation="500,50"  InitialPosition="FloatingOnly">
        <telerik:RadPaneGroup >
            <telerik:RadPane IsHidden="True" ContextMenuTemplate="{x:Null}" TitleTemplate="{StaticResource TitleTemplate}"  x:Name="TooltipHeader" CanUserPin="False">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="90" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0">
                            <TextBlock TextWrapping="Wrap" Margin="5,3,0,0" x:Name="OhlcChartTextBlock" />
                    </StackPanel>
                    <Border Grid.Row="1" BorderBrush="Black" VerticalAlignment="Top" BorderThickness="0 1 0 0">
                        <StackPanel >
                            <TextBlock TextWrapping="Wrap" Margin="5,3,0,0" x:Name="VolumeChartTextBlock" />
                        </StackPanel>
                    </Border>
                    <Border x:Name="TooltipFloatBorder" Grid.Row="2" Margin="0, 3, 0, 0" BorderBrush="Black" VerticalAlignment="Top" BorderThickness="0 1 0 0">
                        <StackPanel x:Name="TooltipFloat">
 
                        </StackPanel>
                    </Border>
                    <Border Grid.Row="3" Margin="0, 3, 0, 0" BorderBrush="Black" VerticalAlignment="Top" BorderThickness="0 1 0 0">
                        <StackPanel>
                            <TextBlock TextWrapping="Wrap" Margin="5,3,0,0" x:Name="Order"/>
                        </StackPanel>
                    </Border>
                </Grid>
            </telerik:RadPane>
        </telerik:RadPaneGroup>
    </telerik:RadSplitContainer>
</telerik:RadDocking>

Thank you
Gerard.

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 13 Jan 2017, 02:12 PM
Hello Gerard,

You can use the SetFloatingSize attached property of the RadDocking control to achieve the desired behavior. For example, add a name to the RadPane(e.g. customPane) that you would like to have dynamic height and apply the following:

public MainWindow()
        {
            this.InitializeComponent();
       RadDocking.SetFloatingSize(this.customPane, new Size(100, Double.NaN));
     }

Another possibility would be to utilize the ToolWindowCreated event and set its height there:
private void dock_ToolWindowCreated(object sender, ElementCreatedEventArgs e)
       {
          var toolWindow = e.CreatedElement as ToolWindow;
          toolWindow.Height = double.NaN;
       }

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Gerard
Top achievements
Rank 1
answered on 16 Jan 2017, 04:25 PM

It's what I wanted, it works perfect!

Another question, when the user modifies the panel height is no longer dynamic, is there any way to reset the panel properties and return to make the height dynamic?

Gerard,
Stefan Nenchev

0
Stefan Nenchev
Telerik team
answered on 17 Jan 2017, 03:28 PM
Hello Gerard,

Such behavior would be expected. However, as the ToolWindow contains a default MS Window, you can set its SizeToContent property to reset the behavior. For example in a button within the RadPane:

private void Button_Click(object sender, RoutedEventArgs e)
       {
           (sender as Button).ParentOfType<ToolWindow>().Height = double.NaN;
           (sender as Button).ParentOfType<Window>().SizeToContent = SizeToContent.WidthAndHeight;
       }

Another possibility would be to set ToolWindow's ResizeMode to NoResize, thus forbidding the resizing by your users.

I hope it helps. 

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Docking
Asked by
Gerard
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Gerard
Top achievements
Rank 1
Share this question
or