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

RadWindow Show() vs ShowDialog() initial size

1 Answer 225 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 05 Jan 2009, 09:28 PM
I am currently referencing the new futures build that was released (RadControls for Silverlight 2008 3 1217 Futures). 

I have noticed a difference in the startup size for a RadWindow when calling ShowDialog() vs Show().  The Show() initializes the window to the 'minimum' size of the user control within the window (this is the behavior I prefer) where as ShowDialog() initializes the window to be the maximum size of the browser window.

Is this expected behavior?  Is there a way to have the ShowDialog() behave like the Show() intial size?
Below is a code sample.
Thank you for your help. 
- Jeremy

Page.xaml
<UserControl x:Class="WindowExample.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    > 
    <Grid x:Name="LayoutRoot" > 
        <StackPanel> 
            <Button x:Name="OpenModalWindowButton" Content="Open Modal Window" Width="150" Height="25" Click="OpenModalWindowButton_Click"/>  
            <Button x:Name="OpenNewWindowButton" Content="Open New Window" Width="150" Height="25" Click="OpenNewWindowButton_Click"/>  
        </StackPanel> 
    </Grid> 
</UserControl> 

Page.xaml.cs
using System.Windows;  
using System.Windows.Controls;  
using Telerik.Windows.Controls;  
 
namespace WindowExample {  
    public partial class Page : UserControl {  
        public Page() {  
            InitializeComponent();  
        }  
 
        private void OpenModalWindowButton_Click(object sender, RoutedEventArgs e) {  
            GetNewWindow().ShowDialog();  
        }  
 
        private void OpenNewWindowButton_Click(object sender, RoutedEventArgs e) {  
            GetNewWindow().Show();  
        }  
 
        private RadWindow GetNewWindow() {  
            RadWindow NewWindow = new RadWindow();  
            NewWindow.Content = new ExampleGrid();  
            NewWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;  
            NewWindow.PreviewClosed += NewWindow_PreviewClosed;  
            NewWindow.PreviewHidden += NewWindow_PreviewHidden;  
            return NewWindow;  
        }  
 
        private void NewWindow_PreviewHidden(object sender, WindowPreviewHiddenEventArgs e) {  
            this.Focus();  
        }  
 
        void NewWindow_PreviewClosed(object sender, WindowPreviewClosedEventArgs e) {  
            this.Focus();  
        }  
    }  
}  
 

ExampleGrid.xaml
<UserControl x:Class="WindowExample.ExampleGrid" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"   
    xmlns:GridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"   
    MinHeight="200">  
    <Grid x:Name="LayoutRoot" > 
        <Controls:RadGridView Name="sampleRadGridView" ColumnsWidthMode="Fill" AutoGenerateColumns="False" ShowGroupPanel="False">  
            <Controls:RadGridView.Columns> 
                <GridView:GridViewDataColumn IsReadOnly="True" DataMemberBinding="{Binding ContactName}">  
                    <GridView:GridViewDataColumn.CellStyle> 
                        <Style TargetType="GridView:GridViewCell">  
                            <Setter Property="Template">  
                                <Setter.Value> 
                                <ControlTemplate> 
                                    <Button x:Name="ActionButton" Content="Some Action" Click="ActionButton_Click"</Button> 
                                </ControlTemplate> 
                                </Setter.Value> 
                                </Setter> 
                        </Style> 
                    </GridView:GridViewDataColumn.CellStyle> 
                </GridView:GridViewDataColumn> 
                <GridView:GridViewDataColumn HeaderText="CustomerID" IsReadOnly="True" UniqueName="CustomerID"    /> 
                <GridView:GridViewDataColumn HeaderText="CompanyName" IsReadOnly="True" UniqueName="CompanyName" /> 
                <GridView:GridViewDataColumn HeaderText="Country" UniqueName="Country" /> 
                <GridView:GridViewDataColumn HeaderText="City" UniqueName="City" /> 
                <GridView:GridViewDataColumn HeaderText="ContactName" UniqueName="ContactName" /> 
            </Controls:RadGridView.Columns> 
        </Controls:RadGridView> 
 
    </Grid> 
</UserControl> 
 

ExampleGrid.xaml.cs
using System;  
using System.Collections.ObjectModel;  
using System.Windows.Controls;  
using Telerik.Windows;  
using Telerik.Windows.Controls.GridView;  
using Telerik.Windows.Controls.GridView.Rows;  
 
namespace WindowExample {  
    public partial class ExampleGrid : UserControl {  
        private ObservableCollection<Customer> dataSource = new ObservableCollection<Customer>();  
 
 
        public ExampleGrid() {  
            InitializeComponent();  
            SetCustomerDataSource();  
            this.sampleRadGridView.AddHandler(GridViewRow.EditEndedEvent, new EventHandler<RecordRoutedEventArgs>(this.OnEditEnded));  
            this.sampleRadGridView.ItemsSource = this.dataSource;  
        }  
 
        private void OnEditEnded(object sender, RecordRoutedEventArgs e) {  
        }  
 
 
        private void SetCustomerDataSource() {  
              
            for (int i = 0; i < 10; i++) {  
                Customer aCustomer = new Customer();  
                aCustomer.CustomerID = i.ToString();  
                aCustomer.ContactName = "Customer " + i.ToString();  
                dataSource.Add(aCustomer);  
            }  
        }  
 
        private void ActionButton_Click(object sender, System.Windows.RoutedEventArgs e) {  
            //Perform some action  
        }  
    }  
    public class Customer {  
        public string CustomerID { getset; }  
        public string CompanyName { getset; }  
        public string Country { getset; }  
        public string City { getset; }  
        public string ContactName { getset; }  
        public bool Bool { getset; }  
    }}  
 


1 Answer, 1 is accepted

Sort by
0
Hristo Borisov
Telerik team
answered on 06 Jan 2009, 01:07 PM
Hi Jeremy,

I have managed to reproduce your problem, and it seems that we have some issue to resolve with the background grid which we use in modal RadWindow. We will work on improving this behavior, and I am sorry for the caused inconvenience. Thank you for raising this issue, your telerik points have been updated.

Best wishes,
Hristo Borisov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Hristo Borisov
Telerik team
Share this question
or