-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
51 lines (41 loc) · 1.63 KB
/
MainWindow.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
#Region "#ChartViewCodeBehind"
Imports System.ComponentModel
Imports System.Windows
Imports System.Windows.Controls
Namespace MvvmChart
Partial Public Class MainWindow
Inherits Window
Private privateViewModel As DailyWeatherViewModel
Public Property ViewModel() As DailyWeatherViewModel
Get
Return privateViewModel
End Get
Private Set(ByVal value As DailyWeatherViewModel)
privateViewModel = value
End Set
End Property
Public Sub New()
InitializeComponent()
ViewModel = New DailyWeatherViewModel()
DataContext = ViewModel
AddHandler ViewModel.PropertyChanged, AddressOf OnViewModelPropertyChanged
End Sub
Private Sub OnViewModelPropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs)
DataContext = Nothing
DataContext = ViewModel
End Sub
End Class
Friend Class WeatherTemplateSelector
Inherits DataTemplateSelector
Public Property AvgSeriesTemplate() As DataTemplate
Public Property MinMaxSeriesTemplate() As DataTemplate
Public Overrides Function SelectTemplate(ByVal item As Object, ByVal container As DependencyObject) As DataTemplate
Dim weatherItem As WeatherItem = TryCast(item, WeatherItem)
If weatherItem Is Nothing Then
Return Nothing
End If
Return If(weatherItem.IsSelected, MinMaxSeriesTemplate, AvgSeriesTemplate)
End Function
End Class
End Namespace
#End Region ' #ChartViewCodeBehind