I installed the Modern UI (Metro) Charts library and added a reference to my project. The following XAML Code should work, but it doens't!
<Window x:Class="T.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Properties="clr-namespace:T.Properties"
xmlns:chart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart"
Title="T" BorderThickness="0" Height="716.467" Width="948.939" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Loaded="MetroWindow_Loaded" WindowTitleBrush="{Binding Source={x:Static Properties:Settings.Default}, Path=Farbe, Mode=TwoWay}">
<Grid>
<chart:RadialGaugeChart ChartSubTitle="Population in percentage"
ChartTitle="Countries by population"
Background="White">
<chart:RadialGaugeChart.Series>
<chart:ChartSeries
ItemsSource="{Binding Data}"
DisplayMember="Name"
ValueMember="Count" />
</chart:RadialGaugeChart.Series>
</chart:RadialGaugeChart>
</Grid>
public ObservableCollection<Diagramm> _Diagramm { get; set; }
public class Diagramm
{
public string Typ { get; set; }
public int Zahl { get; set; }
}
private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
_Diagramm = new ObservableCollection<Diagramm>();
_Diagramm.Add(new Diagramm() { Typ = "Gefahrene Dienste", Zahl = gefahren });
_Diagramm.Add(new Diagramm() { Typ = "Nicht gefahrene Dienste", Zahl = ngefahren });
}
But PieChart
works!
I get a error, that
RadialGaugeChart
is not defined!
How can I fix it? Thanks for all answers!
Looks like you're missing a closing </chart:RadialGaugeChart>
tag in your XAML. Here's a working sample:
XAML:
<Window
xmlns="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:WpfApplication222"
xmlns:MetroChart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart"
x:Class="WpfApplication222.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MyViewModel/>
</Window.DataContext>
<Grid>
<MetroChart:RadialGaugeChart ChartSubTitle="Population in percentage"
ChartTitle="Countries by population"
Background="White">
<MetroChart:RadialGaugeChart.Series>
<MetroChart:ChartSeries
ItemsSource="{Binding Data}"
SeriesTitle="My Population Series"
DisplayMember="Name"
ValueMember="Count" />
</MetroChart:RadialGaugeChart.Series>
</MetroChart:RadialGaugeChart>
</Grid>
</Window>
ViewModel:
public class MyViewModel
{
public ObservableCollection<MyData> Data { get; set; }
public MyViewModel()
{
Data = new ObservableCollection<MyData>
{
new MyData {Name="Country 1", Count = 10 },
new MyData {Name="Country 2", Count = 25 },
new MyData {Name="Country 3", Count = 40 },
};
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.