Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.
<Windowxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:MvvmChart"xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"x:Class="MvvmChart.MainWindow"mc:Ignorable="d"Title="MainWindow"Height="399"Width="656"><Grid><!--region ChartView--><dxc:ChartControlx:Name="chart"SelectionMode="Extended"SeriesSelectionMode="Series"SelectedItem="{Binding Mode=TwoWay, Path=SelectedWeather}"><dxc:XYDiagram2DSeriesItemsSource="{Binding Weather}"><dxc:XYDiagram2D.SeriesItemTemplateSelector><local:WeatherTemplateSelector><local:WeatherTemplateSelector.MinMaxSeriesTemplate><DataTemplate><dxc:RangeAreaSeries2DDataSource="{Binding Data}"ArgumentDataMember="Date"ValueDataMember="MinValue"Value2DataMember="MaxValue"Marker1Visible="False"Marker2Visible="False"Transparency="0.7"CrosshairLabelPattern="{}{S} Day Temperature: Min: {V1}°C Max: {V2}°C"><dxc:RangeAreaSeries2D.SeriesAnimation><dxc:Area2DStretchFromNearAnimationDuration="0:0:1.200"/></dxc:RangeAreaSeries2D.SeriesAnimation></dxc:RangeAreaSeries2D></DataTemplate></local:WeatherTemplateSelector.MinMaxSeriesTemplate><local:WeatherTemplateSelector.AvgSeriesTemplate><DataTemplate><dxc:LineSeries2DDataSource="{Binding Data}"ArgumentDataMember="Date"ValueDataMember="AvgValue"MarkerVisible="True"CrosshairLabelPattern="{}{S} Day Temperature: Avg: {V1}°C"></dxc:LineSeries2D></DataTemplate></local:WeatherTemplateSelector.AvgSeriesTemplate></local:WeatherTemplateSelector></dxc:XYDiagram2D.SeriesItemTemplateSelector></dxc:XYDiagram2D></dxc:ChartControl><!--region ChartView--></Grid></Window>
#Region "#ChartViewCodeBehind"ImportsSystem.ComponentModelImportsSystem.WindowsImportsSystem.Windows.ControlsNamespace MvvmChart
PartialPublicClass MainWindow
Inherits Window
Private privateViewModel As DailyWeatherViewModel
PublicProperty ViewModel() As DailyWeatherViewModel
GetReturn privateViewModel
EndGetPrivateSet(ByVal value As DailyWeatherViewModel)
privateViewModel = value
EndSetEndPropertyPublicSubNew()
InitializeComponent()
ViewModel = New DailyWeatherViewModel()
DataContext = ViewModel
AddHandler ViewModel.PropertyChanged, AddressOf OnViewModelPropertyChanged
EndSubPrivateSub OnViewModelPropertyChanged(ByVal sender AsObject, ByVal e As PropertyChangedEventArgs)
DataContext = Nothing
DataContext = ViewModel
EndSubEndClassFriendClass WeatherTemplateSelector
Inherits DataTemplateSelector
PublicProperty AvgSeriesTemplate() As DataTemplate
PublicProperty MinMaxSeriesTemplate() As DataTemplate
PublicOverridesFunction SelectTemplate(ByVal item AsObject, ByVal container As DependencyObject) As DataTemplate
Dim weatherItem As WeatherItem = TryCast(item, WeatherItem)
If weatherItem IsNothingThenReturnNothingEndIfReturnIf(weatherItem.IsSelected, MinMaxSeriesTemplate, AvgSeriesTemplate)
EndFunctionEndClassEndNamespace#EndRegion ' #ChartViewCodeBehind
#Region "#ViewModelAndModel"ImportsSystemImportsSystem.Collections.GenericImportsSystem.ComponentModelImportsSystem.GlobalizationImportsSystem.Windows.MediaImportsSystem.Xml.LinqNamespace MvvmChart
PublicClass DailyWeatherViewModel
Implements INotifyPropertyChanged
PrivateConst vostokStationName AsString = "Vostok Station"PrivateConst deathValleyName AsString = "Death Valley, NV"PrivateSharedReadOnly coldColor As Color = Color.FromArgb(255, 0, 0, 255)
PrivateSharedReadOnly hotColor As Color = Color.FromArgb(255, 255, 0, 0)
PrivateReadOnly weather_Renamed As List(Of WeatherItem)
PublicEvent PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
PublicReadOnlyProperty Weather() As List(Of WeatherItem)
GetReturn weather_Renamed
EndGetEndPropertyPrivate selectedItem As WeatherItem
PublicProperty SelectedWeather() As WeatherItem
GetReturn selectedItem
EndGetSet(ByVal value As WeatherItem)
If selectedItem Is value ThenReturnEndIfIf selectedItem IsNotNothingThen
selectedItem.IsSelected = FalseEndIf
selectedItem = value
If value IsNotNothingThen
value.IsSelected = TrueEndIf
RaisePropertyChangedEvent("SelectedWeather")
EndSetEndPropertyPublicSubNew()
Dim valleyData As List(Of WeatherRecord) = LoadWeatherData("DeathValley.xml")
Dim vostokData As List(Of WeatherRecord) = LoadWeatherData("VostokStation.xml")
weather_Renamed = New List(Of WeatherItem)() From { _
New WeatherItem(valleyData, hotColor, deathValleyName), _
New WeatherItem(vostokData, coldColor, vostokStationName) _
}
EndSubPrivateFunction LoadWeatherData(ByVal fileName AsString) As List(Of WeatherRecord)
Dim items AsNew List(Of WeatherRecord)()
Dim weatherDocument As XDocument = XDocument.Load(String.Format("../../Data/{0}", fileName))
ForEach element As XElement In weatherDocument.Root.Elements("Weather")
items.Add(WeatherRecord.Load(element))
Next element
Return items
EndFunctionPrivateSub RaisePropertyChangedEvent(ByVal propertyName AsString)
Dim handler = PropertyChangedEvent
If handler IsNotNothingThen
handler.Invoke(Me, New PropertyChangedEventArgs(propertyName))
EndIfEndSubEndClassPublicClass WeatherItem
Implements INotifyPropertyChanged
Private averageLineThickness_Renamed AsInteger = 2Private isSelected_Renamed AsBoolean = FalsePublicProperty AverageLineThickness() AsIntegerGetReturn averageLineThickness_Renamed
EndGetSet(ByVal value AsInteger)
averageLineThickness_Renamed = value
RaisePropertyChanged("AverageLineThickness")
EndSetEndPropertyPublicProperty IsSelected() AsBooleanGetReturn isSelected_Renamed
EndGetSet(ByVal value AsBoolean)
If isSelected_Renamed = value ThenReturnEndIf
isSelected_Renamed = value
RaisePropertyChanged("IsSelected")
EndSetEndPropertyPrivate privateData As List(Of WeatherRecord)
PublicProperty Data() As List(Of WeatherRecord)
GetReturn privateData
EndGetPrivateSet(ByVal value As List(Of WeatherRecord))
privateData = value
EndSetEndPropertyPrivate privateColor As Color
PublicProperty Color() As Color
GetReturn privateColor
EndGetPrivateSet(ByVal value As Color)
privateColor = value
EndSetEndPropertyPrivate privateName AsStringPublicProperty Name() AsStringGetReturn privateName
EndGetPrivateSet(ByVal value AsString)
privateName = value
EndSetEndPropertyPublicSubNew(ByVal data As List(Of WeatherRecord), ByVal color As Color, ByVal name AsString)
Me.Data = data
Me.Color = color
Me.Name = name
EndSub#Region "INotifyPropertyChanged Members"PublicEvent PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
PrivateSub RaisePropertyChanged(ByVal propertyName AsString)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
EndSub#EndRegionEndClassPublicClass WeatherRecord
PublicSharedFunction Load(ByVal element As XElement) As WeatherRecord
Dim culture As CultureInfo = CultureInfo.InvariantCulture
Dim date_Renamed AsDate = Date.Parse(element.Attribute("Date").Value, culture)
Dim min AsDouble = Double.Parse(element.Attribute("Min").Value, culture)
Dim max AsDouble = Double.Parse(element.Attribute("Max").Value, culture)
Dim avg AsDouble = Double.Parse(element.Attribute("Avg").Value, culture)
ReturnNew WeatherRecord(date_Renamed, max, avg, min)
EndFunctionPrivate privateMinValue AsDoublePublicProperty MinValue() AsDoubleGetReturn privateMinValue
EndGetPrivateSet(ByVal value AsDouble)
privateMinValue = value
EndSetEndPropertyPrivate privateMaxValue AsDoublePublicProperty MaxValue() AsDoubleGetReturn privateMaxValue
EndGetPrivateSet(ByVal value AsDouble)
privateMaxValue = value
EndSetEndPropertyPrivate privateAvgValue AsDoublePublicProperty AvgValue() AsDoubleGetReturn privateAvgValue
EndGetPrivateSet(ByVal value AsDouble)
privateAvgValue = value
EndSetEndPropertyPrivate privateDate AsDatePublicProperty [Date]() AsDateGetReturn privateDate
EndGetPrivateSet(ByVal value AsDate)
privateDate = value
EndSetEndPropertyPrivateSubNew(ByVal [date] AsDate, ByVal maxValue AsDouble, ByVal avgValue AsDouble, ByVal minValue AsDouble)
Me.Date = [date]
Me.MaxValue = maxValue
Me.AvgValue = avgValue
Me.MinValue = minValue
EndSubEndClassEndNamespace#EndRegion ' #ViewModelAndModel