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

Radwindow appearing behind child window

11 Answers 359 Views
Window
This is a migrated thread and some comments may be shown as answers.
lakshmi jeeva
Top achievements
Rank 1
lakshmi jeeva asked on 24 Nov 2011, 07:00 PM
HI,

    In silverlight main page i am having button.If i click button it will open a radwindow. It is opening properly.In that radwindow i am having an image. If user single clicks or double clicks a image it has open a another radwindow.

   In imageMouseLeftButton_Down event i have written code like this

  

Private

 

 

Sub moPART_AnswerImage_MouseLeftButtonDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles moPART_AnswerImage.MouseLeftButtonDown

 

     Dim oImageViewer As New Radwindow2
     oImageViewer.ShowDialog()

 


End
Sub

Find below is the xaml for Radwindow2

 

<tkNavigation:RadWindow  

   x:Class="RAMWare.Controls.dlg_PhotoViewer"

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

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

  xmlns:msControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

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

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

  Height="Auto"

  Width="Auto"

  WindowStartupLocation="CenterScreen"

  HorizontalAlignment="Center"

  VerticalAlignment="Center">

  

<Grid x:Name="LayoutRoot" Margin="1">
<Grid.RowDefinitions>

   <RowDefinition Height="Auto" /> 
  <RowDefinition Height="Auto" />

 </Grid.RowDefinitions>

 <StackPanel Orientation="Vertical">
         <Image x:Name="imgPhoto" Height="Auto" Width="Auto" Stretch="Uniform" />
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
 <StackPanel Width="Auto" Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">

 <Button  

x:Name="cmdRotateCounterClockwise"
Content="RotateCounterClockwise"
Width="Auto"
Height="23"
HorizontalAlignment="Left" />

 <Button
    x:Name="cmdOK" 

    Content="OK"

        Width="75"

        Height="23"

        HorizontalAlignment="Center" />

 <Button

 x:Name="cmdRotateClockwise"

 Content="RotateClockwise"

 Width="Auto"

 Height="23"

 HorizontalAlignment="Right" />

 </StackPanel>
<TextBlock

 x:Name="tblError"></TextBlock>

 </StackPanel>

 </StackPanel>

 </Grid> </tkNavigation:RadWindow>

 
If user single click a image present in Radwindow1 it has to open Radwindow2.If user double cliks of a image present in Radwindow1 also opens a Radwindow2.But user double clicks a image, radwindow2 is opening behind Radwindow1 that is parent window.
How to solve the problem?

11 Answers, 1 is accepted

Sort by
0
Manuel
Top achievements
Rank 1
answered on 21 Dec 2011, 04:09 PM
Hi,

I´ve the same problem. When I try open a second window this window is showed behind the first one. Maybe the problem is the MouseLeftButton_Down even.

Any help?
0
Rosi
Telerik team
answered on 21 Dec 2011, 04:25 PM
Hello all,

I suggest you try opening the window by using  a Dispatcher when the code in the event handler of MouseLeftButton_Down event.

Dispatcher.BeginInvoke( () => window.Show());

















Kind regards,
Rosi
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Manuel
Top achievements
Rank 1
answered on 21 Dec 2011, 06:01 PM
Hi Rosi,

Thanks, your tip solve the problem.
Thanks
0
lakshmi jeeva
Top achievements
Rank 1
answered on 01 Feb 2012, 06:02 PM

Hi,

 

    I have used nested dispatcher to show the dialog.But still sometimes radwindow is going behind the parent window? I have followed below website.

     http://www.telerik.com/community/forums/silverlight/window/sl4-upgrade-problems-again-with-windows-newly-opened-window-appearing-behind-previously-opened-window.aspx

   Even i have tried to open a window using timer also. But still problem exists. It is very urgent work.I am using sl4.How to proceed further?

0
Boyan
Telerik team
answered on 06 Feb 2012, 02:22 PM
Hi lakshmi jeeva,

There is an easy way to ensure that the RadWindow is always on top. You have to set the IsTopmost property to true. However setting this to a predefined dialog is a little bit more tricky. If you use a predefined dialog like Confirm or Alert. You have to apply a WindowStyle in order to set IsTopmost. Your code should look something like this:
var dialogParams = new DialogParameters();
Style radAlertStyle = this.Resources["RadAlertStyle1"] as Style;
dialogParams.WindowStyle = radAlertStyle;
RadWindow.Alert(dialogParams);
And the style which is placed in the XAML is the following:
<UserControl.Resources>
    <Style x:Key="RadAlertStyle1" TargetType="telerik:RadWindow">
        <Setter Property="IsTopmost" Value="true"/>
    </Style>
</UserControl.Resources>

Hope this helps. Let us know if you are still having problems.


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
lakshmi jeeva
Top achievements
Rank 1
answered on 07 Feb 2012, 03:11 PM

Hi,
   I have used IsTopMost property. But i am getting error Property 'IsTopMost' is not exist in Telerik.windows.controls.navigation. I am using telerik version 2010.1.422.1030. I have used dispatcher to show the dialog like below

Dispatcher.BeginInvoke( () => window.Show());

But it was not working.SO i have tried nested Dispatcher.It is not working sometimes.If i single click a image the new dialog is opening.If i double a image two window is opening .One window is showing infront of parent window.Another window is going behind a parent window.

 

I have opened the dialog in Image1_MouseLeftButtonDown event. In mouse left button down event i have opened the dialog like below

  

 

moImageViewer =

 

New dlg_PhotoViewer

 

 

 

moImageViewer.ShowDialog()

How to show the dialog when user double cliks as well as single a image without going behind the parent window?

 

0
Boyan
Telerik team
answered on 10 Feb 2012, 10:43 AM
Hi,

You are using a rather old version and IsTopMost property is not existing in this version. It will be best to upgrade to a more recent version. The problem comes form the fact that if the RadWindow shows slower (if it has complex content in it), the background is not disabled until the RadWindow is shown, so in the time before it shows you can make another Click and open another Window. You can attach to the click event and disable another clicks, before the RadWindow is closed.

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
mkk09
Top achievements
Rank 1
answered on 18 Dec 2019, 01:22 PM

Hi,

Can you please tell me how to set 'WindowStyle property IsTopmost' in c# code (business layer). My code has set all properties generic for alert message but only one place I want it to be Topmost so that user should not do anything without pressing OK button on this window.

As I am generating alert message at login stage and when user see that message it is compulsory that user must press ok button before starting to use the application.

Thanks.

0
Vladimir Stoyanov
Telerik team
answered on 20 Dec 2019, 01:42 PM

Hello,

I am assuming that you are using the Predefined Dialogs and the WindowStyle property of the DialogParameters. Feel free to correct me, if I am wrong and provide some more information on the matter. 

If that is indeed the case, can you check the suggestion provided by my colleague here a try and let me know how it goes? 

Regards,
Vladimir Stoyanov
Progress Telerik

Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
mkk09
Top achievements
Rank 1
answered on 23 Dec 2019, 11:02 AM

Hello,
Thanks for your reply. I am using code 
Telerik.Windows.Controls.RadWindow.Confirm(
                    new Telerik.Windows.Controls.DialogParameters
                    {
                        Content = String.Format("You have {0} Days remaining of Free Trail", remainingDay),
                        Closed = (s, args) => Telerik.Windows.Controls.RadWindow.Alert(String.Format("You have {0} Days remaining of Free Trail", remainingDay))
                    });
Problem with this code is that it is generating two messages. I want only one message.
If I remove the line 'Content = ...' then it still generates two messages one empty message box and 2nd with the  message that is given in ‘Close =…’.
Empty message box displays first and then my project’s window displays and then 2nd message box displays with message (means 2nd message box is at the topmost).
I want only one message which must be topmost of the all windows/Boxes and when user clicks on OK button then that message should disappear and user can do rest of the work.
Please note ‘DialogParameters’ is initialised somewhere in my code that has also been used in some other places. I cannot user its property of ‘IsTopmost’ as it will effects on my other code. But I could not find that property in C# code so that this property get active only for a specific place.
If you need further information please feel free to ask me.
Thanks.

0
Dinko | Tech Support Engineer
Telerik team
answered on 26 Dec 2019, 08:27 AM

Hello Muhammad,

Looking at the code snippet, you are opening additional dialog in the Closed event of the Confirm dialog. You can remove the Closed event handler, so only one window is open.

Telerik.Windows.Controls.RadWindow.Confirm(
        new Telerik.Windows.Controls.DialogParameters
        {
            Content = String.Format("You have {0} Days remaining of Free Trail", remainingDay),
            // Closed = (s, args) => Telerik.Windows.Controls.RadWindow.Alert(String.Format("You have {0} Days remaining of Free Trail", remainingDay))
        });

Regarding the DialogParameters. You can change the preserve the WindowStyle property before setting it to the Confirm() in a dummy value. Then you can change to another style with IsTopmostProperty property set to true. After the dialog is closed, you can return the WindowStyle property to its initial value. Check the following code snippet.

private void RadButton_Click(object sender, RoutedEventArgs e)
{
    var windowStyle = new Style(typeof(RadWindow));
    windowStyle.Setters.Add(new Setter(RadWindow.IsTopmostProperty, true));

    var preserveStyle = dialogParameters.WindowStyle;

    dialogParameters.WindowStyle = windowStyle;

    Telerik.Windows.Controls.RadWindow.Confirm(dialogParameters);

    dialogParameters.WindowStyle = preserveStyle;
}

Give this approach a try and let me know if it works for you.

Regards,
Dinko
Progress Telerik

Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Window
Asked by
lakshmi jeeva
Top achievements
Rank 1
Answers by
Manuel
Top achievements
Rank 1
Rosi
Telerik team
lakshmi jeeva
Top achievements
Rank 1
Boyan
Telerik team
mkk09
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Dinko | Tech Support Engineer
Telerik team
Share this question
or