Hi!
I use your RadWindow for all our modal dialogs and I want to display all those dialogs in the center of the screen.
Therefore I use the following things
- SL5
- 2011.3.1323
and the following RadWindow properties:
Unfortunately it seems that, if there is no width or height specified (or only a maxheight), that the radwindow is not rendered in the center of the screen....
Do you have any explanations for this strange behaviour?
Thanks in advance!
I use your RadWindow for all our modal dialogs and I want to display all those dialogs in the center of the screen.
Therefore I use the following things
- SL5
- 2011.3.1323
and the following RadWindow properties:
this
.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
this
.CanMove =
false
;
this
.ResizeMode = ResizeMode.NoResize;
this
.SizeToContent =
true
;
Unfortunately it seems that, if there is no width or height specified (or only a maxheight), that the radwindow is not rendered in the center of the screen....
Do you have any explanations for this strange behaviour?
Thanks in advance!
6 Answers, 1 is accepted
0
Hello,
I tested the issue with the code you provided and the RadWindow appeared in the center of the browser. Could you please provide some more info, are you doing something in order to achieve the bad behavior? Note that if you change the size of the browser after you have shown the RadWindow it will not change its position.
Kind regards,
Boyan
the Telerik team
I tested the issue with the code you provided and the RadWindow appeared in the center of the browser. Could you please provide some more info, are you doing something in order to achieve the bad behavior? Note that if you change the size of the browser after you have shown the RadWindow it will not change its position.
Kind regards,
Boyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Andreas
Top achievements
Rank 1
answered on 17 Feb 2012, 03:19 PM
Actually we derive from Radwindow because we need some custom datatemplate in some parts of our application.
Our derived class looks like this:
Furthermore this is our DataTemplate:
This is the Style:
Thanks for your help!
Andi
Our derived class looks like this:
/// <summary>
/// Provides a base class for Windows
/// </summary>
public
class
CustomWindow : RadWindow
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomWindow"/> class.
/// </summary>
public
CustomWindow()
{
this
.Width = 400;
this
.MaxHeight = 750;
this
.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterOwner;
this
.CanMove =
false
;
this
.ResizeMode = ResizeMode.NoResize;
this
.ContentTemplate = (Application.Current.Resources[
"RadWindowDataTemplate"
])
as
DataTemplate;
this
.Style = (Application.Current.Resources[
"RadWindowStyle"
])
as
Style;
//Needed in order to assign the correct format
this
.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
}
}
Furthermore this is our DataTemplate:
<DataTemplate x:Key=
"RadWindowDataTemplate"
>
<Grid x:Name=
"LayoutRoot"
Margin=
"2"
>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height=
"Auto"
/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row=
"0"
HorizontalScrollBarVisibility=
"Disabled"
VerticalScrollBarVisibility=
"Auto"
BorderThickness=
"0"
>
<ContentPresenter Grid.Row=
"0"
Margin=
"10"
Content=
"{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"
/>
</ScrollViewer>
<StackPanel Grid.Row=
"1"
Orientation=
"Horizontal"
HorizontalAlignment=
"Right"
Margin=
"25,0,15,5"
>
<telerik:RadButton x:Name=
"OKButton"
Content=
"{Binding Path=SaveButtonText}"
Width=
"75"
Height=
"23"
Margin=
"10,0"
HorizontalAlignment=
"Right"
Command=
"{Binding SaveCommand}"
Visibility=
"{Binding ReadOnlyMode, Converter={StaticResource CustomAntiBooleanToVisibilityConverter}}"
/>
<telerik:RadButton x:Name=
"CancelButton"
Content=
"{Binding ApplicationStrings.Label_Cancel, Source={StaticResource ResourceWrapper}}"
Width=
"75"
Height=
"23"
HorizontalAlignment=
"Right"
Command=
"{Binding CancelCommand}"
/>
</StackPanel>
</Grid>
</DataTemplate
This is the Style:
<
Style
x:Key
=
"RadWindowStyle"
TargetType
=
"telerik:RadWindow"
telerik:StyleManager.BasedOn
=
"Metro"
>
<
Setter
Property
=
"ModalBackground"
Value
=
"{StaticResource WindowModalBackground}"
/>
Thanks for your help!
Andi
0
Hi,
I tried to reproduce this using your sample code without any success. You can find my project attached. Could you please examine this and check if I missed something?
Greetings,
Ivo
the Telerik team
I tried to reproduce this using your sample code without any success. You can find my project attached. Could you please examine this and check if I missed something?
Greetings,
Ivo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Andreas
Top achievements
Rank 1
answered on 23 Feb 2012, 09:01 AM
I found out that the described issue only appears, if the Dialog contains a dynamic content.
For example, if you populate a tree with hierarchical data (e.g. 100 items) from the database!, it seems as if the window is centered if there would be no data in it (or only 1 item - see the screenshot radwindow_tree_collapsed). After the data are loaded and expanded, of course you'll get problems because of the position of the radwindow. I got the same behaviour with a listbox.
I provided some screenshots for you attached to this post for further explanation.
Is there a way to "re-arrange" the position of the RadWindow after the data have been loaded? Because of the async call I think that the problem is that the RadWindow is already "adjusted" in the center before the data are even requested - but of course with the wrong height at the end.
Thanks for you help!
For example, if you populate a tree with hierarchical data (e.g. 100 items) from the database!, it seems as if the window is centered if there would be no data in it (or only 1 item - see the screenshot radwindow_tree_collapsed). After the data are loaded and expanded, of course you'll get problems because of the position of the radwindow. I got the same behaviour with a listbox.
I provided some screenshots for you attached to this post for further explanation.
Is there a way to "re-arrange" the position of the RadWindow after the data have been loaded? Because of the async call I think that the problem is that the RadWindow is already "adjusted" in the center before the data are even requested - but of course with the wrong height at the end.
Thanks for you help!
0
Andreas
Top achievements
Rank 1
answered on 23 Feb 2012, 09:23 AM
Would you be so kind as to delete my attached files from the following post.
Unfortunately I uploaded the wrong files and can't change them.
Thanks
Unfortunately I uploaded the wrong files and can't change them.
Thanks
0
Accepted
Hello Andreas,
You are absolutely right that the reason for this behavior is the asynchronous call that fills the items into your RadTreeView. We believe that this is the expected behavior for the property WindowStartupLocation. The easiest way to achieve the desired functionality into your scenario is to handle the SizeChanged event of RadWindow and change its Top and Left properties. Here is sample code:
Regards,
Ivo
the Telerik team
You are absolutely right that the reason for this behavior is the asynchronous call that fills the items into your RadTreeView. We believe that this is the expected behavior for the property WindowStartupLocation. The easiest way to achieve the desired functionality into your scenario is to handle the SizeChanged event of RadWindow and change its Top and Left properties. Here is sample code:
private
void
window_SizeChanged(
object
sender, SizeChangedEventArgs e)
{
var window = (RadWindow)sender;
window.Left = (
this
.ActualWidth - window.ActualWidth) / 2;
window.Top = (
this
.ActualHeight - window.ActualHeight) / 2;
}
Regards,
Ivo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>