<Style x:Key="RadComboBoxStyle" TargetType="telerik:RadComboBox"> <Setter Property="Template" Value="{StaticResource NonEditableComboBox}"/> <Setter Property="EditableTemplate" Value="{StaticResource EditableComboBox}"/> <Setter Property="NonEditableTemplate" Value="{StaticResource NonEditableComboBox}"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="MinHeight" Value="22"/> <Setter Property="Padding" Value="4,0,20,0"/> <Setter Property="Background" Value="{StaticResource MarkerBrush}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="UseLayoutRounding" Value="True"/> <Setter Property="telerik:AnimationManager.AnimationSelector"> <Setter.Value> <telerik:AnimationSelector> <telerik:AnimationGroup AnimationName="Expand"> <telerik:SlideAnimation Direction="In" SlideMode="Top" TargetElementName="PopupRoot"/> </telerik:AnimationGroup> <telerik:AnimationGroup AnimationName="Collapse"> <telerik:SlideAnimation Direction="Out" SlideMode="Top" TargetElementName="PopupRoot"/> </telerik:AnimationGroup> </telerik:AnimationSelector> </Setter.Value> </Setter> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="12"/> <Setter Property="BorderBrush" Value="{StaticResource MainBrush}"/> <Setter Property="Foreground" Value="{StaticResource BasicBrush}"/> <Setter Property="ItemContainerStyle" Value="{StaticResource RadComboBoxItemStyle}"/></Style>public class Strand : BaseObject { private long stranNo; public long StrandNo { get { return this.stranNo; } set { this.stranNo = value; this.OnPropertyChanged("StrandNo"); } } private string strandName; public string StrandName { get { return this.strandName; } set { strandName = value; this.OnPropertyChanged("StrandName"); } } private List<GridData> gridData; public List<GridData> GridData { get { return gridData; } set { gridData = value; this.OnPropertyChanged("GridData"); } } private bool isSelected; public bool IsSelected { get { return isSelected; } set { isSelected = value; this.OnPropertyChanged("IsSelected"); } } }<Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <ItemsControl ItemsSource="{Binding Strands}" Grid.Row="0"> <ItemsControl.ItemTemplate> <DataTemplate> <RadioButton Content="{Binding StrandName}" Margin="5" IsChecked="{Binding IsSelected}" GroupName="Strands"/> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> <Button Content="Rebind" Margin="5" Grid.Row="1" MaxWidth="80" Click="RebindButton_Click"/> <GroupBox Header="Grid" Margin="5" Grid.Row="2"> <telerik:RadGridView x:Name="Grid" Margin="5" IsFilteringAllowed="True" IsReadOnly="True" CanUserFreezeColumns="True" CanUserReorderColumns="False" CanUserResizeColumns="True" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible" ItemsSource="{Binding SelectedStrand.GridData}"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" HeaderTextAlignment="Center" Width="Auto" /> <telerik:GridViewDataColumn Header="Value" DataMemberBinding="{Binding Value}" HeaderTextAlignment="Center" TextAlignment="Left" Width="Auto" /> <telerik:GridViewDataColumn Header="Gauge" HeaderTextAlignment="Center" Width="*" > <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <telerik:RadHorizontalLinearGauge Margin="5" Height="15"> <telerik:HorizontalLinearScale Min="{Binding MinGaugeValue, Source={StaticResource Model}}" Max="{Binding MaxGaugeValue, Source={StaticResource Model}}" LabelFormat="{}{0}" LabelLocation="OverCenter" FontSize="8" FontFamily="Comic Sans MS" FontStyle="Normal" MajorTickLocation="OverOutside" MiddleTickLocation="OverOutside" MinorTickLocation="OverOutside" RangeLocation="OverCenter" MajorTickRelativeHeight="0.2" MiddleTickRelativeHeight="0.1" MinorTickRelativeHeight="0.05" MiddleTicks="1" RelativeHeight="1" RelativeWidth="1" RelativeX="0" RelativeY="0.5" Foreground="Black" Ranges="{Binding VariableRanges, Converter={StaticResource variableRangeToTelerikRanges}}"> <telerik:LinearScale.Indicators> <telerik:Marker telerik:ScaleObject.Location="Inside" telerik:ScaleObject.RelativeWidth="0.04*" telerik:ScaleObject.RelativeHeight="0.5*" Value="{Binding Value}"/> </telerik:LinearScale.Indicators> </telerik:HorizontalLinearScale> </telerik:RadHorizontalLinearGauge> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView> </GroupBox> </Grid><Style TargetType="telerik:RadDatePicker"> <Setter Property="telerikControls:StyleManager.Theme" Value="Windows8" /> <Setter Property="MinHeight" Value="20" /> <Setter Property="Height" Value="20" /> <Setter Property="FontFamily" Value="{StaticResource MyRegularFont}" /> <Setter Property="FontSize" Value="{StaticResource NormalFontSize}" /> </Style>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