I am trying to set the Foreground color of selected RadTreeViewItem but it cannot be set, though, other elements like Background is working.
<
UserControl
>
<
UserControl.Resources
>
<
DataTemplate
x:Key
=
"AdvancedVariableTemplate"
>
<
RadioButton
Checked
=
"itemCont
<
ResourceDictionary
>
<!-- ItemContainerStyleSelector -->
<
Style
x:Key
=
"AdvancedVariableItemContainerStyle"
TargetType
=
"telerik:RadTreeViewItem"
BasedOn
=
"{StaticResource RadTreeViewItemStyle}"
>
<
Setter
Property
=
"Background"
Value
=
"Red"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Green"
/>
</
Style
>
</
ResourceDictionary
>
class
AdvVariableContainerStyleSelector : StyleSelector
{
private
Style darkThemeStyle;
private
Style lightThemeStyle;
public
override
Style SelectStyle(
object
item, DependencyObject container)
{
Configuration config = UserConfigurations.getConfig();
if
(config.AppSettings.Settings[
"CurrentTheme"
] !=
null
)
{
switch
(config.AppSettings.Settings[
"CurrentTheme"
].Value.ToString().ToUpper())
{
case
"LIGHT"
:
return
lightThemeStyle;
case
"STANDARD"
:
return
lightThemeStyle;
case
"DARK"
:
return
darkThemeStyle;
default
:
return
null
;
}
}
else
return
null
;
}
public
Style DarkThemeStyle
{
get
{
return
this
.darkThemeStyle;
}
set
{
this
.darkThemeStyle = value;
}
}
public
Style LightThemeStyle
{
get
{
return
this
.lightThemeStyle;
}
set
{
this
.lightThemeStyle = value;
}
}
}
ainerRadio_Checked"
Content
=
"{Binding CustomName}"
ToolTip
=
"{Binding TooltipString}"
/>
</
DataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"AdvancedGroupSeriesRadioTemplate"
ItemsSource
=
"{Binding LstAppDataSeries}"
>
<
TextBlock
Text
=
"{Binding CustomName}"
FontWeight
=
"Bold"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"AdvancedGroupSideTemplate"
ItemsSource
=
"{Binding LstAppDataSeriesSides}"
>
<
TextBlock
Text
=
"{Binding CustomName}"
FontWeight
=
"Bold"
/>
</
HierarchicalDataTemplate
>
<
VariablesGroup:VariablesHierarchicalTemplate
x:Key
=
"AdvancedVariableItemTemplate"
VariablesGroupsTemplate
=
"{StaticResource AdvancedGroupSideTemplate}"
VariableSideTemplate
=
"{StaticResource AdvancedGroupSeriesRadioTemplate}"
VariableTemplate
=
"{StaticResource AdvancedVariableTemplate}"
/>
<
VariablesGroup:AdvVariableContainerStyleSelector
x:Key
=
"AdvancedVariableStyleSelector"
DarkThemeStyle
=
"{StaticResource AdvancedVariableItemContainerStyle}"
LightThemeStyle
=
"{StaticResource AdvancedVariableItemContainerStyle}"
/>
</
UserControl.Resources
>
<
Grid
>
<
telerik:RadTreeView
x:Name
=
"lstVariablesAdvanced"
SelectedItem
=
"{DynamicResource AdvancedVariableItemContainerStyle}"
VerticalAlignment
=
"Stretch"
Grid.Row
=
"1"
Grid.ColumnSpan
=
"2"
BorderThickness
=
"0,0,0,0"
ScrollViewer.CanContentScroll
=
"False"
IsEditable
=
"True"
SelectionMode
=
"Extended"
ItemsSource
=
"{Binding LstAppDataSeriesGrouping}"
IsDropPreviewLineEnabled
=
"False"
IsDragPreviewEnabled
=
"True"
IsDragTooltipEnabled
=
"False"
MouseDown
=
"lstVariablesAdvanced_MouseDown"
IsSingleExpandPath
=
"True"
IsExpandOnSingleClickEnabled
=
"False"
IsDragDropEnabled
=
"False"
PreviewKeyDown
=
"lstVariables_PreviewKeyDown"
IsLineEnabled
=
"True"
ItemTemplateSelector
=
"{StaticResource AdvancedVariableItemTemplate}"
ItemContainerStyleSelector
=
"{StaticResource AdvancedVariableStyleSelector}"
Margin
=
"10,0,6,0"
>
</
telerik:RadTreeView
>
</
Grid
>
</
UserControl
>