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

Trouble with CenterOnParent - ShowDialog vs. Show

3 Answers 159 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 15 May 2009, 09:44 PM
So I have a very simple UserControl...

<UserControl x:Class=".... my class ..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
Loaded="OnPageLoaded"
    >
<Grid>
<telerik:RadWindow x:Name="cChooser" 
Header="Choose Something" 
Hidden="OnWindowHidden" 
WindowStartupLocation="CenterParent"
WindowAnimation="OnShow"
ResizeMode="CanMinimize"
Background="{StaticResource GreyGradient}">
</telerik:RadWindow>
</Grid>
</UserControl>

--- code behind ---

/// <summary>
/// OnPageLoaded
/// </summary>
private void 
OnPageLoaded(object sender, RoutedEventArgs e)
{
cChooser.ShowDialog();
}

Question 1:

RadWindow.Show() is correctly locating the window in the center of the surrounding grid.  RadWindow.ShowDialog() places the window in the upper left hand corner of the containing UIElement (the grid).  How can I get ShowDialog to locate the window correctly?

Question 2:
If I remove the surrounding grid the .Show will throw an error:  'Value does not fall within expected range...' (.ShowDialog works just as if there were a surrounding grid)

Thank you for your attention to this. 

3 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 18 May 2009, 07:51 AM
Hello Jim,

1. We are planning to remove the CenterParent option because the window shouldn't have parent. You could use CenterScreen instead.

Your case works at our side. Could you please open a support ticket and send us a sample project to test locally?

2. Because of the limitation of Silverlight, we are moving the Window's popup at the most top Panel in the Visual Tree. If you remove the Grid you don't have any panels in the Visual Tree and that is why it is failing.

Regards,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Jim
Top achievements
Rank 1
answered on 18 May 2009, 02:14 PM
Hi Miro -

I am disappointed to hear that you would intend to remove 'center on parent' as this would be useful to me.  Consider a screen with left hand navigation and a user-content area on the right.  Centering the a dialog on the content area is a useful concept. 

I created a very simple solution that demonstrates my inability to utilize ShowDialog.  If you create a default silverlight 2 application and replace the Page.xaml with:

<

 

UserControl x:Class="TelerikShowDialog.Page"

 

 

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"

 

 

Loaded="UserControl_Loaded"

 

 

>

 

 

 

<Grid>

 

 

 

<telerik:RadWindow x:Name="cQuestionChooser"

 

 

Header="Choose A Question"

 

 

WindowStartupLocation="CenterScreen"

 

 

WindowAnimation="OnShow"

 

 

ResizeMode="CanMinimize"

 

 

Width="300"

 

 

Height="260">

 

 

 

<Grid Margin="10,10,10,10">

 

 

 

<Grid.RowDefinitions>

 

 

 

<RowDefinition Height="Auto" />

 

 

 

<RowDefinition Height="Auto" />

 

 

 

<RowDefinition Height="*" />

 

 

 

<RowDefinition Height="Auto" />

 

 

 

</Grid.RowDefinitions>

 

 

 

<TextBlock Grid.Row="0" Text="Questions" />

 

 

 

<Border Grid.Row="1" />

 

 

 

<ListBox Grid.Row="2" x:Name="cListBox"

 

 

DisplayMemberPath="QuestionDesc"

 

 

MinHeight="40" HorizontalAlignment="Stretch"/>

 

 

 

<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center">

 

 

 

<Button x:Name="cOKButton" Content="OK" Margin="5,5,5,5" IsEnabled="False"/>

 

 

 

<Button x:Name="cCancelButton" Content="Cancel" Margin="5,5,5,5" />

 

 

 

</StackPanel>

 

 

 

</Grid>

 

 

 

</telerik:RadWindow>

 

 

 

</Grid>

 

</

 

UserControl>

 



the code behind is:

namespace

 

TelerikShowDialog

 

{

 

public partial class Page : UserControl

 

{

 

public Page()

 

{

InitializeComponent();

}

 

private void UserControl_Loaded(object sender, RoutedEventArgs e)

 

{

cQuestionChooser.ShowDialog();

}

}

}


In this case CenterScreen places the window in the bottem right hand corner of the browser.  I must simply be doing something wrong as this is about as basic as it gets...
0
Miroslav Nedyalkov
Telerik team
answered on 19 May 2009, 02:13 PM
Hello Jim,

We will remove CenterOnParent, because it is just not correct - the Window should not have a parent. But don't worry - you will still be able to do it.

About the problem with the centering of the Window control - I found out that it was a bug in the Window, but it was fixed - it wasn't working correctly in the project you sent with the other ticket, but when I changed the assemblies with the latest official ones it worked as expected. 

Please, download the latest official version of RadControls for Silverlight (2009.1.413).

Regards,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Tags
Window
Asked by
Jim
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Jim
Top achievements
Rank 1
Share this question
or