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

Resize RadWindow content

2 Answers 319 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 14 Oct 2013, 09:32 PM
Hello,

I am creating an application where I need to have 4 RadWindows and each window has assigned a UserControl to its content.
I was taking a look to the window examples in the WPF Demo so I took some code from there, this is how I created the windows:
RadWindow window = new RadWindow();
        RadWindow window2 = new RadWindow();
        RadWindow window3 = new RadWindow();
        RadWindow window4 = new RadWindow();
 
        public MainWindow()
        {
            InitializeComponent();
 
            window.Header = "Window1";
            window.Owner = Application.Current.MainWindow;
            window.CanClose = false;
 
            window2.Header = "Window2";
            window2.Owner = Application.Current.MainWindow;
            window2.CanClose = false;
 
            window3.Header = "Window3";
            window3.Owner = Application.Current.MainWindow;
            window3.CanClose = false;
 
            window4.Header = "Window4";
            window4.Owner = Application.Current.MainWindow;
            window4.CanClose = false;
                         
            this.Loaded += OnExampleLoaded;
            this.Unloaded += OnExampleUnloaded;
 
        }


void OnExampleUnloaded(object sender, RoutedEventArgs e)
        {
            window.Close();
            window2.Close();
            window3.Close();
            window4.Close();
        }
 
        void OnExampleLoaded(object sender, RoutedEventArgs e)
        {
            double dblHeight = (this.ActualHeight / 2) - 15;
            double dblWidth = (this.ActualWidth / 2) - 20;
 
            window.Height = dblHeight;
            window.Width = dblWidth;
 
            window2.Height = dblHeight;
            window2.Width = dblWidth;
 
            window3.Height = dblHeight;
            window3.Width = dblWidth;
 
            window4.Height = dblHeight;
            window4.Width = dblWidth;
 
            window.Left = 10;
            window.Top = 34;
 
            window2.Left = dblWidth + 20;
            window2.Top = 34;
 
            window3.Left = 10;
            window3.Top = dblHeight + 44;
 
            window4.Left = dblWidth + 20;
            window4.Top = dblHeight + 44;
 
            window2.Content = new MyControl();
 
            window.Show();
            window2.Show();
            window3.Show();
            window4.Show();
        }

And the first attached image is how this look.

MyControl has 3 charts and a label:

<UserControl
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="ScoreBoard.MyControl"
             mc:Ignorable="d" Height="358.566" Width="391.232">
    <Grid Margin="0,10,10,10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="132*"/>
            <RowDefinition Height="133*"/>
            <RowDefinition Height="27*"/>
        </Grid.RowDefinitions>
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
 
               
        <telerik:Label Content="Times" Margin="10,9,10,10" FontSize="36" FontWeight="Bold" HorizontalContentAlignment="Center" Grid.ColumnSpan="2"/>
 
        <telerik:RadCartesianChart x:Name="chartTimes1" Margin="10" Grid.Row="1" FontSize="11" FontWeight="Normal" >
            <telerik:RadCartesianChart.Behaviors>
                <telerik:ChartPanAndZoomBehavior PanMode="Both" ZoomMode="Both"/>
            </telerik:RadCartesianChart.Behaviors>
        </telerik:RadCartesianChart>
 
        <telerik:RadCartesianChart x:Name="chartTimes2" Margin="10" Grid.Row="2" FontSize="11" FontWeight="Normal" Grid.RowSpan="2" >
            <telerik:RadCartesianChart.Behaviors>
                <telerik:ChartPanAndZoomBehavior PanMode="Both" ZoomMode="Both"/>
            </telerik:RadCartesianChart.Behaviors>
        </telerik:RadCartesianChart>
        <telerik:RadCartesianChart Grid.Column="1" Margin="10" Grid.Row="1">
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:CategoricalAxis/>
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:BarSeries>
                <telerik:BarSeries.DataPoints>
                    <telerik:CategoricalDataPoint Category="{x:Null}" IsSelected="False" Label="10" Value="10"/>
                    <telerik:CategoricalDataPoint Category="{x:Null}" IsSelected="False" Label="20" Value="20"/>
                    <telerik:CategoricalDataPoint Category="{x:Null}" IsSelected="False" Label="30" Value="30"/>
                </telerik:BarSeries.DataPoints>
            </telerik:BarSeries>
        </telerik:RadCartesianChart>
 
    </Grid>
</UserControl>

In the design of MyControl I change the size of the control and the charts changes its size whether I make it smaller or larger, as you can see in the image MyControl.

But when I assign MyControl to the window content and I change the size of the window, the control appears to be fixed in the center but It doesn't change its size.

Do I need to configure or assign MyControl in a different way?

Regards,

Alberto


2 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 15 Oct 2013, 12:10 PM
Hi Alberto,

Thanks for the provided sample code.

Looks like the UserControl with the Chart has Width and Height set which prevents changing its size when resizing the Window. As a suggestion you can just remove the Width and Height of the UserControl - this way it will take the size of the Window.

Please try the explained above and let us know if this works for you.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Alberto
Top achievements
Rank 1
answered on 15 Oct 2013, 03:01 PM
Hi Kalin,

You're right, I just needed to remove the Width and Height.

Thanks a lot,

Alberto
Tags
Window
Asked by
Alberto
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Alberto
Top achievements
Rank 1
Share this question
or