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.
To implement a selection in the MVVM style, enable the selection feature using the ChartControl.SelectionMode property. Set this property to a value different from None.
<Windowxmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"Title="MainWindow"Height="720"Width="1280"x:Class="MVVM_Selection.MainWindow"dx:ThemeManager.Theme="Office2013"><Grid><Grid.ColumnDefinitions><ColumnDefinitionWidth="3*"/><ColumnDefinitionWidth="2*"/></Grid.ColumnDefinitions><dxc:ChartControlGrid.Column="0"Margin="4,4,2,4"SelectionMode="Single"SelectedItem="{Binding Path=SelectedCountry, Mode=TwoWay}"><dxc:ChartControl.Palette><dxc:Office2013Palette/></dxc:ChartControl.Palette><dxc:ChartControl.Titles><dxc:TitleContent="Top 10 Countries By Area"HorizontalAlignment="Center"/></dxc:ChartControl.Titles><dxc:ChartControl.Legend><dxc:LegendHorizontalPosition="LeftOutside"VerticalPosition="Top"Orientation="Vertical"IndentFromDiagram="2"/></dxc:ChartControl.Legend><dxc:SimpleDiagram2D><dxc:PieSeries2DDataSource="{Binding Path=CountriesData}"ArgumentDataMember="Name"ValueDataMember="Area"LegendTextPattern="{}{A}"><dxc:PieSeries2D.Model><dxc:BorderlessFlatPie2DModel/></dxc:PieSeries2D.Model></dxc:PieSeries2D></dxc:SimpleDiagram2D></dxc:ChartControl><dxc:ChartControlGrid.Column="1"Margin="2,4,4,4"><dxc:ChartControl.Palette><dxc:Office2013Palette/></dxc:ChartControl.Palette><dxc:ChartControl.Titles><dxc:TitleContent="{Binding Path=SelectedCountry.Name, Mode=OneWay}"HorizontalAlignment="Center"/></dxc:ChartControl.Titles><dxc:XYDiagram2D><dxc:XYDiagram2D.AxisX><dxc:AxisX2D><dxc:AxisX2D.WholeRange><dxc:RangeAutoSideMargins="False"SideMarginsValue="0"/></dxc:AxisX2D.WholeRange></dxc:AxisX2D></dxc:XYDiagram2D.AxisX><dxc:XYDiagram2D.AxisY><dxc:AxisY2D><dxc:AxisY2D.WholeRange><dxc:Rangedxc:AxisY2D.AlwaysShowZeroLevel="False"/></dxc:AxisY2D.WholeRange><dxc:AxisY2D.Title><dxc:AxisTitleContent="Population, millons"/></dxc:AxisY2D.Title></dxc:AxisY2D></dxc:XYDiagram2D.AxisY><dxc:AreaSeries2DDataSource="{Binding Path=SelectedCountry.PopulationDynamics}"ArgumentDataMember="Year"ValueDataMember="Population"/></dxc:XYDiagram2D></dxc:ChartControl></Grid></Window>
Imports MVVM_Selection.Model
ImportsSystem.Collections.GenericImportsSystem.ComponentModelImportsSystem.GlobalizationImportsSystem.Xml.LinqNamespace MVVM_Selection.ViewModel
PublicClass DashboardViewModel
Implements INotifyPropertyChanged
PrivateShared instance_Renamed As DashboardViewModel
PrivateReadOnly countriesData_Renamed As List(Of CountryStatisticInfo)
Private selectedCountry_Renamed As CountryStatisticInfo
PublicEvent PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
PublicSharedReadOnlyProperty Instance() As DashboardViewModel
GetIf instance_Renamed IsNothingThen
instance_Renamed = New DashboardViewModel()
EndIfReturn instance_Renamed
EndGetEndPropertyPublicReadOnlyProperty CountriesData() As List(Of CountryStatisticInfo)
GetReturn countriesData_Renamed
EndGetEndPropertyPublicProperty SelectedCountry() As CountryStatisticInfo
GetReturn selectedCountry_Renamed
EndGetSet(ByVal value As CountryStatisticInfo)
If selectedCountry_Renamed IsNot value Then
selectedCountry_Renamed = value
OnPropertyChanged("SelectedCountry")
EndIfEndSetEndPropertyPublicSub PopulateData(ByVal filepath AsString)
countriesData_Renamed.AddRange(CountriesInfoDataReader.Load(filepath))
selectedCountry_Renamed = countriesData_Renamed(0)
EndSubPrivateSubNew()
countriesData_Renamed = New List(Of CountryStatisticInfo)()
EndSubPrivateSub OnPropertyChanged(ByVal propertyName AsString)
Dim propertyChangedEventHendler As PropertyChangedEventHandler = PropertyChangedEvent
If propertyChangedEventHendler IsNotNothingThen
propertyChangedEventHendler(Me, New PropertyChangedEventArgs(propertyName))
EndIfEndSubEndClassFriendClass CountriesInfoDataReader
PrivateSharedFunction LoadStatistic(ByVal populationDynamic As XElement) As List(Of PopulationStatisticByYear)
Dim statistic AsNew List(Of PopulationStatisticByYear)()
ForEach populationDynamicItem As XElement In populationDynamic.Elements("PopulationStatisticByYear")
Dim year AsInteger = Integer.Parse(populationDynamicItem.Element("Year").Value)
Dim population AsLong = Long.Parse(populationDynamicItem.Element("Population").Value)
Dim urbanPercent AsDouble = Double.Parse(populationDynamicItem.Element("UrbanPercent").Value, CultureInfo.InvariantCulture)
Dim popDynamicItem AsNew PopulationStatisticByYear(year, CDbl(population) / 1000000.0, urbanPercent)
statistic.Add(popDynamicItem)
Next populationDynamicItem
Return statistic
EndFunctionPublicSharedFunction Load(ByVal path AsString) As List(Of CountryStatisticInfo)
Dim doc As XDocument = XDocument.Load(path)
Dim data AsNew List(Of CountryStatisticInfo)()
ForEach countryInfo As XElement In doc.Root.Elements("CountryInfo")
Dim name AsString = countryInfo.Element("Name").Value
Dim areaSqKm AsDouble = UInteger.Parse(countryInfo.Element("AreaSqrKilometers").Value)
Dim statistic As List(Of PopulationStatisticByYear) = LoadStatistic(countryInfo.Element("Statistic"))
Dim countryInfoInstance AsNew CountryStatisticInfo(name, areaSqKm / 1000000, statistic)
data.Add(countryInfoInstance)
Next countryInfo
Return data
EndFunctionEndClassEndNamespace
ImportsSystem.Collections.GenericNamespace MVVM_Selection.Model
PublicClass CountryStatisticInfo
PrivateReadOnly name_Renamed AsStringPrivateReadOnly area_Renamed AsDoublePrivateReadOnly statistics As List(Of PopulationStatisticByYear)
PublicReadOnlyProperty Name() AsStringGetReturn name_Renamed
EndGetEndProperty' Measured in millions of square kilometers.PublicReadOnlyProperty Area() AsDoubleGetReturn area_Renamed
EndGetEndPropertyPublicReadOnlyProperty PopulationDynamics() As List(Of PopulationStatisticByYear)
GetReturn statistics
EndGetEndPropertyPublicSubNew(ByVal name AsString, ByVal area AsDouble, ByVal statistics As List(Of PopulationStatisticByYear))
Me.name_Renamed = name
Me.area_Renamed = area
Me.statistics = statistics
EndSubEndClassPublicClass PopulationStatisticByYear
Private year_Renamed AsIntegerPrivate populationMillionsOfPeople AsDoublePrivate urbanPercent_Renamed AsDoublePublicReadOnlyProperty Year() AsIntegerGetReturn year_Renamed
EndGetEndProperty' Measured in Millions of people.PublicReadOnlyProperty Population() AsDoubleGetReturn populationMillionsOfPeople
EndGetEndPropertyPublicReadOnlyProperty UrbanPercent() AsDoubleGetReturn urbanPercent_Renamed
EndGetEndPropertyPublicReadOnlyProperty RuralPercent() AsDoubleGetReturn100 - urbanPercent_Renamed
EndGetEndPropertyPublicSubNew(ByVal year AsInteger, ByVal populationMillionsOfPeople AsDouble, ByVal urbanPercent AsDouble)
Me.year_Renamed = year
Me.populationMillionsOfPeople = populationMillionsOfPeople
Me.urbanPercent_Renamed = urbanPercent
EndSubEndClassEndNamespace