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
If you have any questions, submit a ticket to our Support Center.
No
Your feedback is appreciated.
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
Privacy Preference Center
When you visit a Developer Express Inc (“DevExpress”) website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. While the information does not usually directly identify you, it can give you a more personalized web experience. Because DevExpress respects your right to privacy, you can choose to disallow/disable the use of certain cookies. Click on different category headings to learn more and change our default settings. Keep in mind that blocking some types of cookies may impact your experience on the site and may affect the services DevExpress is able to offer to you. You cannot opt-out of our use of strictly necessary cookies as they are used to ensure the proper functioning of our Websites (such as remembering your settings, allowing you to log into your account, and other similar purposes). You may, however, opt-out of receiving and our use of non-essential cookies (including preference, functional, and targeting cookies) by changing your settings for each category listed below.
[Videos]
Our use of cookies may also collect information about what videos you have watched on our websites. You may opt-out of these cookies by changing your settings for functional and advertising cookies. We will ask you to review and update your choices at least once every two (2) years. By continuing to allow us to use these cookies you explicitly consent to our use of cookies and our disclosure of what videos you have watched on our Websites to our video hosting providers, such as YouTube, for a period of up to two (2) years.
Manage Consent Preferences
Strictly Necessary Cookies
Always Active
These cookies are necessary for the website to function properly and cannot be disabled. They are usually set in response to actions initiated by you – actions that amount to a request for services, such as setting your privacy preferences, logging onto the website, or populating website forms. You can set your browser to block or alert you about these cookies, but certain portions of the site will not work properly when these cookies are disabled. These cookies do not store any personally identifiable information.
Performance Cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand page popularity and determine how visitors move around the site. All information collected by these cookies are aggregated and therefore anonymous. If you disallow/disable these cookies, we will not know when you have visited our site and we will not be able to monitor its performance.
Functional Cookies
These cookies allow the website to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we have added to our pages. If you disallow/disable these cookies, some or all of these services may fail to function properly.
Targeting Cookies
These cookies may be set through our site by our advertising partners. They may be used by advertising partners to build a profile of your interests and display relevant advertisements on other sites. While these cookies do not store personal information, they do identify your browser and internet device. If you disallow/disable these cookies, you will experience less targeted advertising.