I would like to know how to get my CustomMapping to run the Apply method. I have a list of animals and the speed of the animals should control the colour of the treemapitem. However when the animals speed changes then the treemap tiles don't change colour but on startup the colours visible. They just never change. When the animals size changes the tiles do reflect the changes. How do I run the Apply method?
<telerik:RadTreeMap x:Name=
"treeMap"
ItemsSource=
"{Binding TreeMapList}"
LayoutStrategy=
"Squarified"
>
<telerik:RadTreeMap.TypeDefinitions>
<telerik:TypeDefinition TargetTypeName=
"TreeMapItem"
ValuePath=
"AnimalSize"
LabelPath=
"Animal"
ToolTipPath=
"ToolTip"
>
<telerik:TypeDefinition.Mappings>
<local:ValueColourMapping MinValue=
"{Binding MinCurrentSpeed}"
MaxValue=
"{Binding MaxCurrentSpeed}"
Field=
"CurrentSpeed"
/>
</telerik:TypeDefinition.Mappings>
</telerik:TypeDefinition>
</telerik:RadTreeMap.TypeDefinitions>
</telerik:RadTreeMap>
Hi,
I have a RadTreeMap that's working perfectly except that I want its labels to be centered vertically and horizontally within each rectangle.
I'm also using a Colorizer:
<telerik:TypeDefinition.Mappings>
<telerik:DesaturationColorizer From="1" To="0.1" StartColor="#d9ac26"/>
</telerik:TypeDefinition.Mappings>
...so, when I attempt to change use a TextBlock with the proper alignment:
<Style TargetType="telerik:RadTreeMapItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<TextBlock Text="{Binding Label}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
...it successfully centers the labels, but I lose the colorizing effect. How can I make the TextBlock respect the intended colorizing?
Wayne
I have the following Apply method that has been working:
protected override void Apply(Telerik.Windows.Controls.TreeMap.RadTreeMapItem treemapItem, object dataItem)
{
BranchIntegrationDetails details = dataItem as BranchIntegrationDetails;
SolidColorBrush brush = PickBrush(details);
// Apply the color
treemapItem.Background = brush; // Apply additional text
IntegrationStatisticsControl statisticsControl = new IntegrationStatisticsControl()
{
VerticalAlignment = System.Windows.VerticalAlignment.Bottom,
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
Foreground = ForegroundBrush,
Margin = new System.Windows.Thickness(0,0,10,0)
};
statisticsControl.SetValue(Grid.RowSpanProperty, 2);
Grid grid = treemapItem.ChildrenOfType<Grid>().ElementAt(1);
grid.Children.Add(statisticsControl);
}
The expected output can been in the first picture (see "expected.png").
When I add the theme file into my app.xaml:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="StyleResources.xaml" />
<ResourceDictionary Source="TelerikTheme/Telerik.Windows.Controls.xaml"/>
<ResourceDictionary Source="TelerikTheme/Telerik.Windows.Controls.DataVisualization.xaml"/> <!-- this one is bad -->
<ResourceDictionary Source="TelerikTheme/Telerik.Windows.Controls.Navigation.xaml"/>
</ResourceDictionary.MergedDictionaries>
The control that I want to apply does not anymore (see "unexpected.png"). The same code is still working, I can see my control is added to the Grid, just I could not know why it is not showing.
01.
<
telerik:RadTreeMap
x:Name
=
"TreeMap"
Grid.Row
=
"0"
Grid.Column
=
"2"
02.
ClipToBounds
=
"True"
>
03.
04.
<
telerik:RadTreeMap.LayoutStrategy
>
05.
<
telerik:SliceDiceStrategy
Orientation
=
"Horizontal"
/>
06.
</
telerik:RadTreeMap.LayoutStrategy
>
07.
08.
<
telerik:RadTreeMap.TypeDefinitions
>
09.
<
telerik:TypeDefinition
TargetTypeName
=
"ModelInfo"
10.
ValuePath
=
"Value"
ChildrenPath
=
"Children"
LabelPath
=
"Name"
11.
ItemStyle
=
"{StaticResource IcicleStyle}"
/>
12.
13.
<
telerik:TypeDefinition
TargetTypeName
=
"GroupInfo"
14.
ValuePath
=
"Value"
ChildrenPath
=
"Children"
LabelPath
=
"Name"
15.
ItemStyle
=
"{StaticResource IcicleStyle}"
/>
16.
17.
<
telerik:TypeDefinition
TargetTypeName
=
"EventInfo"
18.
ValuePath
=
"Value"
LabelPath
=
"Name"
19.
ItemStyle
=
"{StaticResource IcicleStyle}"
/>
20.
21.
</
telerik:RadTreeMap.TypeDefinitions
>
22.
23.
</
telerik:RadTreeMap
>
1.
<
Style
x:Key
=
"IcicleStyle"
TargetType
=
"telerik:RadTreeMapItem"
>
2.
<
Setter
Property
=
"Control.Background"
Value
=
"White"
/>
3.
<
Setter
Property
=
"MaxHeight"
Value
=
"50"
/>
4.
<
Setter
Property
=
"FontFamily"
Value
=
"Segoe UI"
/>
5.
<
Setter
Property
=
"FontWeight"
Value
=
"SemiBold"
/>
6.
<
Setter
Property
=
"Margin"
Value
=
"-1"
/>
7.
<
Setter
Property
=
"Padding"
Value
=
"0"
/>
8.
</
Style
>