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

RadWindow resizing to content

1 Answer 144 Views
Window
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 26 Jun 2014, 04:09 PM
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?

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 30 Jun 2014, 10:13 AM
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.
 
Tags
Window
Asked by
Erin
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or