Different styles for ToolWindow

2 posts, 0 answers
  1. Marcelo
    Marcelo avatar
    28 posts
    Member since:
    Jul 2010

    Posted 16 Apr 2012 Link to this post

    Hi guys,

    I'm using the RadDocking control to show some charts and grids.
    Today, the user can set the RadPanel as Float and save it.

    I have a property on my ViewModel that says if User can make changes on these panels. Let's call it "IsAllowChanges".

    What I want is, when IsAllowChanges is false, set the Header, Background and borders of "Float" RadPane to "Transparent". And come back to original Header, Background and borders when IsAllowChanges is true.

    As the RadDocking don't allow me to set the ToolWindow's Style directly, I did a general style. 

    <SolidColorBrush x:Key="ToolWindow_Background" Color="Transparent"/>
            <SolidColorBrush x:Key="ToolWindow_OuterBorderBrush" Color="Transparent"/>
            <telerik:Office_BlackTheme x:Key="Theme"/>
            <SolidColorBrush x:Key="ToolWindow_InnerBorderBrush" Color="Transparent"/>
            <Style TargetType="telerik:RadSplitContainer">
                <Setter Property="InitialPosition" Value="DockedLeft"/>
                <Setter Property="Background" Value="{StaticResource ToolWindow_Background}"/>
            <Style TargetType="telerik:RadPaneGroup">
                <Setter Property="Background" Value="{StaticResource ToolWindow_Background}"/>
            <DataTemplate x:Key="toolWindowTemplate">
            <Style TargetType="telerik:ToolWindow">
                <Setter Property="IsTabStop" Value="False"/>
                <Setter Property="Background" Value="{StaticResource ToolWindow_Background}"/>
                <Setter Property="BorderBrush" Value="{StaticResource ToolWindow_OuterBorderBrush}"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Template">
                        <ControlTemplate TargetType="telerik:ToolWindow">
                            <Grid x:Name="VisualRoot" Background="Transparent">
                                <Border Background="Transparent">
                                    <!--<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" CornerRadius="4">
                                        <Border BorderBrush="{StaticResource ToolWindow_InnerBorderBrush}" BorderThickness="1" CornerRadius="3">-->
                                            <Grid Background="Transparent">
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="*"/>
                                                <!--<Border x:Name="HeaderElement" Background="Transparent" Grid.Column="0" Padding="3 1" Grid.Row="0">
                                                            <telerik:MouseBinding Command="telerikDocking:RadDockingCommands.PaneHeaderMenuOpen">
                                                                    <telerik:MouseGesture MouseAction="RightClick"/>
                                                    <ContentPresenter x:Name="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}"/>
                                                <telerik:RadButton x:Name="CloseButton" Grid.Column="1" Command="telerik:WindowCommands.Close" Margin="1 1 3 1" Grid.Row="0" Style="{StaticResource ToolWindow_CloseButtonStyle}"/>-->
                                                <ContentPresenter x:Name="Content" Grid.ColumnSpan="2" Content="{TemplateBinding Content}" Margin="3 0 3 3" Grid.Row="1"/>

    The problem is, how would I change the styles propertys (or the entire style of the ToolWindow ) when the IsAllowChanges changes?

    I don't know if I made myself clear, so see on attachments an example...

  2. Dani
    Dani avatar
    848 posts

    Posted 18 Apr 2012 Link to this post

    Hello Marcelo,

    As the style you use is implicit, it always gets applied to ToolWindows. You can either set it a key and make it explicit and then have two different explicit ToolWindow styles in order to apply them conditionally. Or you can leave it as implicit, place it in a separate resource dictionary and have another resource dictionary with the second implicit ToolWindow style. You can then dynamically add or remove resource dictionaries to the merged dictionaries collection in App.xaml.cs depending on which style you need.

    I hope this will be helpful.

    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top