3. Finally define the data title display list
Front desk:
<usercontrol x:class= "Wpfapplication4.radarcharttitlelist"
Xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns:mc= "http://schemas.openxmlformats.org/markup-compatibility/2006"
Xmlns:d= "http://schemas.microsoft.com/expression/blend/2008"
Mc:ignorable= "D"
d:designheight= "d:designwidth=" loaded= "radarcharttitlelist_onloaded" >
<UserControl.Resources>
<style x:key= "Itemcontainer" targettype= "{x:type ListBoxItem}" >
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "{x:type ListBoxItem}" >
<border x:name= "Iconborder" background= "Transparent" cornerradius= "4" borderthickness= "0" >
<contentpresenter/>
</Border>
<ControlTemplate.Triggers>
<trigger property= "IsSelected" value= "true" >
<setter targetname= "Iconborder" property= "BitmapEffect" >
<Setter.Value>
<outerglowbitmapeffect glowcolor= "Transparent" glowsize= "5"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<listbox x:name= "MyListBox" itemssource= "{Binding}" itemcontainerstyle= "{StaticResource Itemcontainer}" Focusvisualstyle= "{x:null}" >
<ListBox.Template>
<ControlTemplate>
<stackpanel background= "Transparent" isitemshost= "True" ></StackPanel>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate>
<grid horizontalalignment= "left" verticalalignment= "Center" background= "Transparent" >
<Grid.ColumnDefinitions>
<columndefinition width= "Auto" ></ColumnDefinition>
<columndefinition width= "*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<grid horizontalalignment= "Center" margin= "10,0" background= "Transparent" >
<ellipse fill= "{Binding Color}" height= "6" width= "6" horizontalalignment= "right" verticalalignment= "Center" > </Ellipse>
<canvas verticalalignment= "center" horizontalalignment= "Center" >
<path fill= "{Binding color}" height= "5" strokethickness= "1" stroke= "{Binding color}" verticalalignment= "Center" Data= "m-10,0 l10,0" ></Path>
</Canvas>
</Grid>
<textblock grid.column= "1" text= "{Binding Name}" foreground= "White" background= "Transparent" ></textblock >
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>
Background:
<summary>
The interactive logic of Radarcharttitlelist.xaml
</summary>
public partial class Radarcharttitlelist:usercontrol
{
Public Radarcharttitlelist ()
{
InitializeComponent ();
}
<summary>
Data
</summary>
Public list<chartitem> Itemsoure
{
get {return (list<chartitem>) GetValue (itemsoureproperty);}
set {SetValue (Itemsoureproperty, value);}
}
public static readonly DependencyProperty Itemsoureproperty = Dependencyproperty.register ("Itemsoure", typeof (List <ChartItem>),
typeof (Radarchartcontrol), New PropertyMetadata (New List<chartitem> ()));
private void Radarcharttitlelist_onloaded (object sender, RoutedEventArgs e)
{
This. DataContext = itemsoure;
}
}
WPF Custom Radar Chart