-
Notifications
You must be signed in to change notification settings - Fork 500
/
Copy pathScenario6.xaml.vb
91 lines (77 loc) · 3.69 KB
/
Scenario6.xaml.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'*********************************************************
'
' Copyright (c) Microsoft. All rights reserved.
' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
'
'*********************************************************
Imports Windows.UI.Xaml
Imports Windows.UI.Xaml.Controls
Imports Windows.UI.Xaml.Navigation
Imports Windows.UI.Xaml.Media
Imports SDKTemplate
''' <summary>
''' An empty page that can be used on its own or navigated to within a Frame.
''' </summary>
Partial Public NotInheritable Class Scenario6
Inherits SDKTemplate.Common.LayoutAwarePage
' A pointer back to the main page. This is needed if you want to call methods in MainPage such
' as NotifyUser()
Private rootPage As MainPage = MainPage.Current
Public Sub New()
Me.InitializeComponent()
End Sub
''' <summary>
''' Invoked when this page is about to be displayed in a Frame.
''' </summary>
''' <param name="e">Event data that describes how this page was reached. The Parameter
''' property is typically used to configure the page.</param>
Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs)
' We need to hook the DropDownOpened event of the ComboBox so that we are notified when it is opened
' so that we can swap out the WebView control for a Rectangle that uses a fill brush created by
' the WebViewBrush to give the illusion that the WebView is still there. This solves airspace
' problems that occur since the WebView is hosted in its own HWND and content cannot be rendered
' on top of it.
AddHandler ComboBox1.DropDownOpened, AddressOf ComboBox1_DropDownOpened
' Now we need to hook the DropDownClosed event so that we can undo what we did on DropDownOpened
' and swap the WebView back.
AddHandler ComboBox1.DropDownClosed, AddressOf ComboBox1_DropDownClosed
' Select on of the items in the ComboBox
ComboBox1.SelectedIndex = 0
' Ensure that our Rectangle used to simulate the WebView is not shown initially
Rect1.Visibility = Windows.UI.Xaml.Visibility.Collapsed
WebView6.Navigate(New Uri("http://www.bing.com"))
End Sub
''' <summary>
''' This is the click handler for the 'Solution' button.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
Private Sub Solution_Click(sender As Object, e As RoutedEventArgs)
Rect1.Visibility = Windows.UI.Xaml.Visibility.Visible
End Sub
''' <summary>
''' When the ComboBox opens we have an airspace conflict and the ComboBox cannot render its content over
''' the WebView. Therefore, we create a WebViewBrush and set the WebView as its source and call the Redraw() method
''' which will take a visual snapshot of the WebView. We then use that brush to fill our Rectangle.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
'<snippetWebViewBrushCode>
Private Sub ComboBox1_DropDownOpened(sender As Object, e As Object)
If Rect1.Visibility = Windows.UI.Xaml.Visibility.Visible Then
Dim b As New WebViewBrush()
b.SourceName = "WebView6"
b.Redraw()
Rect1.Fill = b
WebView6.Visibility = Windows.UI.Xaml.Visibility.Collapsed
End If
End Sub
Private Sub ComboBox1_DropDownClosed(sender As Object, e As Object)
WebView6.Visibility = Windows.UI.Xaml.Visibility.Visible
Rect1.Fill = New SolidColorBrush(Windows.UI.Colors.Transparent)
End Sub
'</snippetWebViewBrushCode>
End Class