?
Solved

Silverlight RadWindow Height

Posted on 2011-03-07
3
Medium Priority
?
1,256 Views
Last Modified: 2013-12-17
Experts
Please see the attached code.
There is a RadWindow which is having a content as TriggerUI.xaml .
this TriggerUI.xaml is open in the RadWindow.
Now my problem is I need to measure the height of the RadWindow  or TriggerUI.
Actually the Height of TriggerUI.xaml is declared as Auto .
But on runtime I need to know the actual height of the TriggerUI or its parents Height ( that is the RadWindow(either of them is needed)
I have tried in the following manner.

1. double y2 = (double) (winAddEditSchedule.Height);
2.double y2 = (double)(triggerUI.Parent as FrameworkElement).Height;
But all are failed.

I need help in this matter.
Thanking you,
Anindya
private void ShowScheduleTaskWindow ( decimal parentIID, ScheduledParentType parentType, string parentDescription )
        {
            GeneralTransform mdiTransform = this.TransformToVisual ( Application.Current.RootVisual );
            Point pntMdi = mdiTransform.Transform ( new Point ( 0, 0 ) );
            double y1 = pntMdi.Y;
            //MessageBox.Show(y1.ToString());
            if ( !Globals.AllowMultipleSchedules )
            {
                TriggerUI triggerUI = new TriggerUI ( parentIID, parentType, parentDescription );
                

                RadWindow winAddEditSchedule = new RadWindow ( );
                double y2 = (double) (winAddEditSchedule.Height);
                if ((y1 + y2) > Globals.VisibleScreenHeight)
                {
                    pntMdi.Y = y1 - ((y1 + y2) - Globals.VisibleScreenHeight) - 150;
                }
                winAddEditSchedule.Content = triggerUI;
                winAddEditSchedule.Header = "Create / Edit Schedule";
                winAddEditSchedule.Width = 425;
                winAddEditSchedule.Left = pntMdi.X + 23;



//the full function is here
private void ShowScheduleTaskWindow ( decimal parentIID, ScheduledParentType parentType, string parentDescription )
        {
            GeneralTransform mdiTransform = this.TransformToVisual ( Application.Current.RootVisual );
            Point pntMdi = mdiTransform.Transform ( new Point ( 0, 0 ) );
            double y1 = pntMdi.Y;
            //MessageBox.Show(y1.ToString());
            if ( !Globals.AllowMultipleSchedules )
            {
                TriggerUI triggerUI = new TriggerUI ( parentIID, parentType, parentDescription );
                

                RadWindow winAddEditSchedule = new RadWindow ( );
                double y2 = (double)(triggerUI.Parent as FrameworkElement).Height;
                if ((y1 + y2) > Globals.VisibleScreenHeight)
                {
                    pntMdi.Y = y1 - ((y1 + y2) - Globals.VisibleScreenHeight) - 150;
                }
                winAddEditSchedule.Content = triggerUI;
                winAddEditSchedule.Header = "Create / Edit Schedule";
                winAddEditSchedule.Width = 425;
                winAddEditSchedule.Left = pntMdi.X + 23;
                if ( ( pntMdi.Y + triggerUI.Height ) > Application.Current.RootVisual.RenderSize.Height )
                {
                    double diff = ( pntMdi.Y + triggerUI.Height ) - Application.Current.RootVisual.RenderSize.Height;
                    winAddEditSchedule.Top = pntMdi.Y - ( diff + 20 );
                }
                else
                {
                    winAddEditSchedule.Top = pntMdi.Y;
                }
                winAddEditSchedule.Margin = this.Margin;
                winAddEditSchedule.BorderThickness = new Thickness ( -22, -22, -22, -22 );

                winAddEditSchedule.ResizeMode = ResizeMode.NoResize;
                winAddEditSchedule.Closed += new EventHandler<WindowClosedEventArgs> ( winAddEditSchedule_Closed );
                triggerUI.OnScheduleDeleted += new EventHandler ( triggerUI_OnScheduleDeleted );
                triggerUI.OnScheduleSaved += new EventHandler ( triggerUI_OnScheduleSaved );
                winAddEditSchedule.ShowDialog ( );
            }
            else
            {
                SearchScheduleTaskUI taskScheduleUI = new SearchScheduleTaskUI ( parentIID, parentType );
                RadWindow winSearchSchedule = new RadWindow ( );
                winSearchSchedule.Content = taskScheduleUI;
                winSearchSchedule.Header = "Create Schedule";
                winSearchSchedule.Width = 670;
                winSearchSchedule.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterOwner;
                winSearchSchedule.BorderBackground = new SolidColorBrush ( Color.FromArgb ( 0xFF, 0x3C, 0x59, 0x07 ) );
                winSearchSchedule.ResizeMode = ResizeMode.NoResize;
                winSearchSchedule.ShowDialog ( );
            }
        }

Open in new window

0
Comment
Question by:ANINDYA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:Gewgala
ID: 35059140
If your content control's height is set to auto, then it will auto-fill the height available in the rad window.  This means that you need to specify a height on the RadWindow control itself in order for the Height property of the RadWindow to return something of value.  If the RadWindow does not have a height specificied then I believe it will just auto-crunch to the content inside of it.  I don't believe it will return a value for the Height property under such a scenario.  I believe your problem is that you need to either specify a height on the content itself, or specify a height on the RadWindow.

One thing you could also try is accessing the ActualHeight property.  Does this give you a value, when accessing the property in the control content xaml or the rad window property itself?
0
 

Author Comment

by:ANINDYA
ID: 35064840
Expert Gewqala
As you said to try the ActualHeight property of the Radwindow should be tried so here I have tried .
please have a look on that and let me know what more can I do under that circumstances.
q.JPG
0
 
LVL 7

Accepted Solution

by:
Gewgala earned 2000 total points
ID: 35065195
The error "object reference not set to an instance of an object" is because the object itself is null.  In other words, (triggerUI.Parent as FrameworkElement) is returning null, and then you are attempting to access a property named ActualHeight on a null object.

I would just try to do triggerUI.ActualHeight, and if that doesn't work you're going to need to get a reference to the actual RadWindow that has the triggerUI.xaml user control loaded in it in order to access the element's height.

If triggerUI.ActualHeight doesn't work, then get a reference to the RadWindow that is hosting it and try RadWindowReference.Height and/or RadWindowReference.ActualHeight
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question