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"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" SizeToContent="WidthAndHeight">
        <DockPanel Height="300">
            <CheckBox x:Name="checkbox" Width="200" IsChecked="True" />
            <Grid Width="200" Background="Blue">
                <Grid.Style>
                    <Style TargetType="{x:Type Grid}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=checkbox, Path=IsChecked}" Value="True">
                                <Setter Property="Visibility" Value="Visible" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=checkbox, Path=IsChecked}" Value="False">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
            </Grid>
        </DockPanel>
    </Window>

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

  2. Kalin
    Admin
    Kalin avatar
    1207 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):
    http://feedback.telerik.com/Project/143/Feedback/Details/130576-sizetocontent-stops-working-when-expander-is-expanded

    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" />
        ...
    </DockPanel>

    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.

    Regards,
    Kalin
    Telerik
     
    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top