I’m trying to convert the windows application to wpf application, and everything is fine but i was Struck at this point converting the bellow declaration not working out in code of wpf.
these are windows declarations,
Dim screenwidth As String = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Dim screenheight As String = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
i googled to find the equivalent class properties for these declarations and i got some thing, but those are existing but not working at the point of time i’m trying to use them at
“PointToScreen(New Point(0,0))”
they are:
If i use these in my code:
Dim screenwidth As String = System.Windows.SystemParameters.VirtualScreenWidth
Dim screenheight As String = System.Windows.SystemParameters.VirtualScreenHeight
‘(OR)
Dim screenwidth As String = System.Windows.SystemParameters.PrimaryScreenWidth
Dim screenheight As String = System.Windows.SystemParameters.PrimaryScreenHeight
With MyPanel
.PointToScreen(New Point(SystemParameters.VirtualScreenWidth, 0)) ' Getting Exception in this line
.Height = (80 / 1080) * screenheight
.Width = screenwidth
.Background = New SolidColorBrush(Colors.Transparent)
End With
Am getting the exception as Invalid Operation Exception saying that
“The visual is not connected to PresentationSource.”
i alreadt tried this post http://social.msdn.microsoft.com/Forums/en/wpf/thread/f3c982a1-ca16-4821-bf08-f6dd8ff8d829
, but i want to try it out using PointToScreen only.
How can i resolve this ????
Please help me
Hi try this to get the Width and height of screen.
The exception is because you are pointing Mypanel before it is rendered. Do it like this
I hope this will help.