I have a template selector that I would like to work with the RadPanelBarItem items presenter. Unfortunatley the template is never called. I am doing the following:
<telerik:RadPanelBar Grid.Row="1" x:Name="PART_RAD_PANEL_BAR" Margin="5,5,0,0" ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged, Path=ExperimentCollection.ExperimentTriggerCollection, NotifyOnSourceUpdated=True}" > </telerik:RadPanelBar>And am using the following Style for the RadPanelBarItem (Cut for brevity)
<Style x:Key="PanelBarItemKey" TargetType="{x:Type telerik:RadPanelBarItem}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="White" /> <GradientStop Color="Gainsboro" Offset="0.43" /> <GradientStop Color="#FFADADAD" Offset="0.44" /> <GradientStop Color="#FFD4D4D4" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="#FF848484" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Foreground" Value="Black" /> <Setter Property="Padding" Value="3" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Stretch" /> <Setter Property="HeaderTemplate" Value="{StaticResource PanelBarItemTemplate}" /> <Setter Property="ItemsSource" Value="{Binding SelectedTrigger}" /> <Setter Property="ItemTemplateSelector" Value="{StaticResource TriggerTemplateSelectorKey}" /> <Setter Property="ChildItemsTemplate">
And the following Template Selector:
Public Class TriggerTemplateSelector Inherits DataTemplateSelector Public Overrides Function SelectTemplate(ByVal item As Object, ByVal container As DependencyObject) As DataTemplate If item IsNot Nothing Then Dim et As ExperimentTrigger = CType(item, ExperimentTrigger) Dim element As FrameworkElement element = TryCast(container, FrameworkElement) Select Case et.TriggerType Case "Timer" Return TryCast(element.FindResource("TimerTriggerTemplate"), DataTemplate) Case "Damage" Return TryCast(element.FindResource("TriggerDamageTemplate"), DataTemplate) Case "IED Detonation" Return TryCast(element.FindResource("TriggerDetonationTemplate"), DataTemplate) End Select Else Return Nothing End If Return Nothing End FunctionEnd ClassThe Items in the RadPanelBarItems need to call the template selector which I thought would be called by setting the ItemTemplateSelector in the Style, but this does not seem to be the case. How can I call my template selector in the RadPanelBarItem Style?
I am using the following to link to further illustrate.
If I do the following in XAML the template selector is called but I don't know how many RadPabelBarItems I will have:
<telerik:RadPanelBar Grid.Row="1" Margin="5,5,0,0" > <telerik:RadPanelBarItem Header="Test" Style="{x:Null}" ItemTemplateSelector="{StaticResource TriggerTemplateSelectorKey}" ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged, Path=ExperimentCollection.ExperimentTriggerCollection, NotifyOnSourceUpdated=True}" /></telerik:RadPanelBar>
I have not had any luck with this so I am currently trying to do it procedurally. Is this possible to do this in XAML?
Regards,
Joseph
Hi all.
I need to sync position and width for two RadCartesianChart's.
XAML:
style definition for chart's:<Stylex:Key="ChartStyle"TargetType="telerik:RadCartesianChart"><SetterProperty="Template"><Setter.Value><ControlTemplateTargetType="{x:Type telerik:RadChartBase}"><BorderBackground="{TemplateBinding Background}"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"><Grid><ContentPresenterx:Name="emptyContent"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"Content="{TemplateBinding EmptyContent}"ContentTemplate="{TemplateBinding EmptyContentTemplate}"IsHitTestVisible="False"Visibility="Collapsed"/><Canvasx:Name="adornerContainer"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"Background="Transparent"><Canvasx:Name="labelContainer"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Canvasx:Name="renderSurface"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Borderx:Name="plotAreaDecoration"Style="{TemplateBinding PlotAreaStyle}"/></Canvas></Canvas></Canvas></Grid></Border></ControlTemplate></Setter.Value></Setter></Style>
chart #1:<telerik:RadCartesianChartx:Name="DeviationChart"Grid.Row="1"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"MaxZoom="{Binding MaxZoom}"MouseMove="Chart_OnMouseMove"PanOffset="{Binding PanOffset,Mode=TwoWay}"Style="{StaticResource ChartStyle}"Zoom="{Binding Zoom,Mode=TwoWay}"><telerik:ScatterAreaSeriesx:Name="DeviationSeries"Fill="{Binding DeviationFillColor}"ItemsSource="{Binding DeviationPoints}"Opacity="{Binding DeviationOpacity}"Stroke="{Binding DeviationColor}"StrokeMode="AllButPlotLine"StrokeThickness="{Binding DeviationThickness}"Tag="{BindingPath=Settings.PressureEU,Converter={StaticResource PressureEUConverter}}"XValueBinding="X"YValueBinding="Y"></telerik:ScatterAreaSeries><!-- ... --><telerik:RadCartesianChart.HorizontalAxis><telerik:LinearAxisx:Name="DeviationChartHorizontalAxis"MajorTickStyle="{StaticResource TopChartTickStyle}"Maximum="{Binding Path=ChartSettings.ChartMaxX}"Minimum="{Binding Path=ChartSettings.ChartMinX}"ShowLabels="False"Visibility="Collapsed"/></telerik:RadCartesianChart.HorizontalAxis><telerik:RadCartesianChart.VerticalAxis><telerik:LinearAxisx:Name="DeviationChartVerticalAxis"Title="{Binding Path=PressureBaseEUText}"LabelFormat="N2"LastLabelVisibility="Visible"Maximum="{Binding DeviationChartSettings.ChartMaxY}"Minimum="{Binding DeviationChartSettings.ChartMinY}"Style="{StaticResource LinearAxisStyle}"/></telerik:RadCartesianChart.VerticalAxis><telerik:RadCartesianChart.Grid><telerik:CartesianChartGridMajorXLinesRenderMode="All"MajorYLinesRenderMode="All"StripLinesVisibility="None"Style="{StaticResource CartesianChartGridStyle}"/></telerik:RadCartesianChart.Grid><telerik:RadCartesianChart.Behaviors><telerik:ChartPanAndZoomBehaviorPanMode="Both"ZoomMode="Both"/><telerik:ChartTrackBallBehaviorShowIntersectionPoints="False"ShowTrackInfo="True"SnapMode="None"/></telerik:RadCartesianChart.Behaviors></telerik:RadCartesianChart>
chart #2:<telerik:RadCartesianChartx:Name="Chart"Grid.Row="1"MaxZoom="{Binding MaxZoom}"MouseMove="Chart_OnMouseMove"PanOffset="{Binding PanOffset,Mode=TwoWay}"Style="{StaticResource ChartStyle}"Zoom="{Binding Zoom,Mode=TwoWay}"><telerik:ScatterAreaSeriesx:Name="ElevationSeries"Fill="{Binding ElevationFillColor}"ItemsSource="{Binding RealElevationsPoints}"Opacity="{Binding ElevationOpacity}"Stroke="{Binding ElevationColor}"StrokeMode="AllButPlotLine"StrokeThickness="{Binding ElevationThickness}"XValueBinding="X"YValueBinding="Y"><telerik:ScatterLineSeries.LegendSettings><telerik:SeriesLegendSettingsTitle="{Binding ElevationDescription}"/></telerik:ScatterLineSeries.LegendSettings><!-- ... --><telerik:ScatterLineSeries.TrackBallInfoTemplate><DataTemplate><BorderBackground="#FFEBEBEB"><TextBlockText="{Binding Path=DataPoint.XValue, StringFormat=\{0:N3\}}"/></Border></DataTemplate></telerik:ScatterLineSeries.TrackBallInfoTemplate></telerik:ScatterAreaSeries><telerik:RadCartesianChart.HorizontalAxis><telerik:LinearAxisx:Name="ChartHorizontalAxis"LabelFormat="N0"Maximum="{Binding Path=ChartSettings.ChartMaxX}"Minimum="{Binding Path=ChartSettings.ChartMinX}"Style="{StaticResource LinearAxisStyle}"/></telerik:RadCartesianChart.HorizontalAxis><telerik:RadCartesianChart.VerticalAxis><telerik:LinearAxisx:Name="ChartVerticalAxis"HorizontalLocation="Left"LabelFormat="N2"Maximum="{Binding ChartSettings.ChartMaxY}"Minimum="{Binding ChartSettings.ChartMinY}"Style="{StaticResource LinearAxisStyle}"/></telerik:RadCartesianChart.VerticalAxis><telerik:RadCartesianChart.Grid><telerik:CartesianChartGridMajorXLinesRenderMode="All"MajorYLinesRenderMode="All"StripLinesVisibility="None"Style="{StaticResource CartesianChartGridStyle}"/></telerik:RadCartesianChart.Grid><telerik:RadCartesianChart.Behaviors><telerik:ChartPanAndZoomBehaviorPanMode="Both"ZoomMode="Both"/><telerik:ChartTrackBallBehaviorShowIntersectionPoints="False"ShowTrackInfo="True"SnapMode="None"/></telerik:RadCartesianChart.Behaviors></telerik:RadCartesianChart>
Code:But this doesn't work. Any ideas? Best regards, George.publicoverridevoidOnApplyTemplate(){base.OnApplyTemplate();if(!Chart.IsTemplateApplied) Chart.ApplyTemplate();if(!DeviationChart.IsTemplateApplied) DeviationChart.ApplyTemplate();var chartpad = Chart.Template.FindName("plotAreaDecoration", Chart)asBorder;var deviationpad = DeviationChart.Template.FindName("plotAreaDecoration", DeviationChart)asBorder;if(null!= chartpad &&null!= deviationpad){chartpad.SizeChanged += (sender, args) =>{// Set position of left edge of chart #1 relative to chart #2objectleft = chartpad.GetValue(Canvas.LeftProperty);deviationpad.SetValue(Canvas.LeftProperty, left);// Set width of chart #1 relative to chart #2objectwidth = chartpad.GetValue(WidthProperty);deviationpad.SetValue(WidthProperty, width);};}}