RadWindow resizing to content

2 posts, 0 answers
  1. Erin
    Erin avatar
    1 posts
    Member since:
    Jun 2014

    Posted 26 Jun 2014 Link to this post

    I would like a side panel to expand the window size like the behaviour in this code:

    <Window x:Class="WpfApp.MainWindow"
            Title="MainWindow" SizeToContent="WidthAndHeight">
        <DockPanel Height="300">
            <CheckBox x:Name="checkbox" Width="200" IsChecked="True" />
            <Grid Width="200" Background="Blue">
                    <Style TargetType="{x:Type Grid}">
                            <DataTrigger Binding="{Binding ElementName=checkbox, Path=IsChecked}" Value="True">
                                <Setter Property="Visibility" Value="Visible" />
                            <DataTrigger Binding="{Binding ElementName=checkbox, Path=IsChecked}" Value="False">
                                <Setter Property="Visibility" Value="Collapsed" />

    The RadWindow does not seem to resize itself, even when setting SizeToContent="True". Is it possible to do this with RadWindow?

  2. Kalin
    Kalin avatar
    1360 posts

    Posted 30 Jun 2014 Link to this post

    Hi Erin,

    We are already aware of such issues with the SizeToContent behavior of RadWindow. We have a logged item in our Feedback portal for a similar scenario which you can track (we will definitely consider your scenario as well):

    However what I can suggest you as work around for this scenario would be to hook to the Checked/Unchecked events of the CheckBox and using a single handler to manually set the size of the Window to be equal to the actual Size of the DockPanel:

    <DockPanel Height="300" x:Name="DockPanel">
        <CheckBox x:Name="checkbox" Width="200" IsChecked="True" Checked="checkbox_Checked" Unchecked="checkbox_Checked" />

    And code behind:

    private void checkbox_Checked(object sender, RoutedEventArgs e)
        if (this.DockPanel.ActualWidth != 0 && this.DockPanel.ActualHeight != 0)
            this.Width = this.DockPanel.ActualWidth;
            this.Height = this.DockPanel.ActualHeight;

    I'm sorry for any inconvenience caused. If you have any other issues or concerns, please do not hesitate to contact us.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top