Implicit Styles not work with RadWindow

3 posts, 0 answers
  1. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 28 Aug 2014 Link to this post

    How to easy applay my style to my RadWindow?
    Here is my view and style that I use.


     
    <telerik:RadWindow x:Class="RadGauge.ChildWindow1"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
               xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
               Width="400" Height="300"
               >
     
     
        <telerik:RadWindow.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/RadGauge;component/Style/RadWindowStyle.xaml" />
                    <telerik:Windows8ResourceDictionary />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </telerik:RadWindow.Resources>
     
        <Grid x:Name="LayoutRoot" Margin="2">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
     
            <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
            <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        </Grid>
    </telerik:RadWindow>

     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls;
     
    namespace RadGauge
    {
        public partial class ChildWindow1 : RadWindow
        {
            public ChildWindow1()
            {
                InitializeComponent();
            }
     
            private void OKButton_Click(object sender, RoutedEventArgs e)
            {
                this.DialogResult = true;
            }
     
            private void CancelButton_Click(object sender, RoutedEventArgs e)
            {
                this.DialogResult = false;
            }
        }
    }


    Style xaml

     
    <ResourceDictionary
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"           
            xmlns:animation="clr-namespace:Telerik.Windows.Controls.Animation;assembly=Telerik.Windows.Controls"     
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"    
            xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"  
            xmlns:telerik1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
            mc:Ignorable="c">
     
        <ResourceDictionary.MergedDictionaries>              
            <telerik:Windows8ResourceDictionary />                      
        </ResourceDictionary.MergedDictionaries>
     
        <SolidColorBrush x:Key="WindowBorderBackground" Color="#FFCCE4FC"/>
        <SolidColorBrush x:Key="WindowModalBackground" Color="#333333FF"/>
     
        <Thickness x:Key="WindowButtonPadding">4 1</Thickness>
        <Thickness x:Key="WindowButtonMargin">1 3 0 2</Thickness>
     
        <Style x:Key="WindowButtonStyle" TargetType="telerik:RadButton">
            <Setter Property="Padding" Value="{StaticResource WindowButtonPadding}"/>
            <Setter Property="Margin" Value="{StaticResource WindowButtonMargin}"/>
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerik:RadButton">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To="0.7"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To="0.3"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle Fill="Transparent"/>
                            <ContentPresenter x:Name="Content" Margin="{TemplateBinding Padding}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
     
        <Style x:Key="WindowResizeThumbStyle" TargetType="Thumb">
            <Setter Property="MinWidth" Value="5"/>
            <Setter Property="MinHeight" Value="5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Thumb">
                        <Rectangle Fill="Transparent"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
     
        <ControlTemplate x:Key="RadWindowTemplate" TargetType="telerikNavigation:RadWindow">
            <Grid x:Name="LayoutRoot">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="Disabled"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused"/>
                        <VisualState x:Name="Unfocused"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="DragStates">
                        <VisualState x:Name="NotDragging"/>
                        <VisualState x:Name="Dragging"/>
                        <VisualState x:Name="Resizing"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="WindowStates">
                        <VisualState x:Name="NormalWindow"/>
                        <VisualState x:Name="MaximizedRestricted"/>
                        <VisualState x:Name="Maximized">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="WindowOuterBorder" Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>0</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentOuterBorder" Storyboard.TargetProperty="Margin">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>0</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderButtons" Storyboard.TargetProperty="Margin">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>0</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Minimized">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderButtons" Storyboard.TargetProperty="Margin">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>0</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="HorizontalAlignment">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <HorizontalAlignment>Left</HorizontalAlignment>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="VerticalAlignment">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <VerticalAlignment>Top</VerticalAlignment>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="WindowOuterBorder" BorderThickness="1" Grid.RowSpan="2" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" MinHeight="30"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid x:Name="Header" Background="Red" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition   Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Thumb x:Name="titleThumb" Grid.ColumnSpan="2" Style="{StaticResource WindowResizeThumbStyle}" Background="Gray" />
                            <Grid Grid.Column="0" Margin="2 0 0 0" Background="Black" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter x:Name="IconContent"  
                                        Grid.Column="0"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Margin="2"
                                        Content="{TemplateBinding Icon}"
                                        ContentTemplate="{TemplateBinding IconTemplate}"/>
                                <ContentControl x:Name="HeaderContent" Background="HotPink"
                                        Grid.Column="1"
                                        IsTabStop="False"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Center"
                                        HorizontalContentAlignment="Stretch"
                                        Content="{TemplateBinding Header}"
                                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                                        FontSize="{telerik:Windows8Resource ResourceKey=FontSizeL}"
                                        FontFamily="{telerik:Windows8Resource ResourceKey=FontFamilyLight}"
                                        Foreground="{telerik:Windows8Resource ResourceKey=MainBrush}"/>
                            </Grid>
                            <Border x:Name="PART_HeaderButtonsBorder" Grid.Column="1" Background="Fuchsia" >
                                <StackPanel x:Name="HeaderButtons" Orientation="Horizontal" Margin="0 0 3 0" Background="#FF0EE818"  >
                                    <telerik:RadButton x:Name="PART_MinimizeButton"
                                            Command="telerik:WindowCommands.Minimize"
                                            Style="{StaticResource WindowButtonStyle}"
                                            Visibility="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip telerik:LocalizationManager.ResourceKey="Minimize"/>
                                        </ToolTipService.ToolTip>
                                        <Path Fill="{telerik1:Windows8Resource ResourceKey=MainBrush}" Data="M0,0 L10,0 L10,2 L0,2 z" Height="2" Width="10" VerticalAlignment="Bottom" Margin="0 0 0 6"/>
                                    </telerik:RadButton>
                                    <telerik:RadButton x:Name="PART_RestoreButton"
                                            Command="telerik:WindowCommands.Restore"
                                            Style="{StaticResource WindowButtonStyle}"
                                            Visibility="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip telerik:LocalizationManager.ResourceKey="Restore"/>
                                        </ToolTipService.ToolTip>
                                        <Path
                                                Fill="{telerik:Windows8Resource ResourceKey=MainBrush}"
                                                Width="10"
                                                Height="10"
                                                Data="M0,2.0009768 L8,2.0009768 L8,10.000977 L0,10.000977 z M1.0026064,0 L10.000999,0.015881581 L10.000999,9.0009928 L9.0009499,9.0010004 L9.0006638,1.0009757 L0.98699945,0.99989343 z"/>
                                    </telerik:RadButton>
                                    <telerik:RadButton x:Name="PART_MaximizeButton"
                                            Command="telerik:WindowCommands.Maximize"
                                            Style="{StaticResource WindowButtonStyle}"
                                            Visibility="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip telerik:LocalizationManager.ResourceKey="Maximize"/>
                                        </ToolTipService.ToolTip>
                                        <Path Data="M1,1 L9,1 L9,9 L1,9 z" Stroke="{telerik1:Windows8Resource ResourceKey=MainBrush}" StrokeThickness="2" Width="10" Height="10"/>
                                    </telerik:RadButton>
                                    <telerik:RadButton x:Name="PART_CloseButton"
                                            Command="telerik:WindowCommands.Close"
                                            Style="{StaticResource WindowButtonStyle}"
                                            Visibility="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip telerik:LocalizationManager.ResourceKey="Close"/>
                                        </ToolTipService.ToolTip>
                                        <Path Data="M1,1 L9,9 M1.0000687,9.0000982 L9.0000687,1.0000986" Stroke="{telerik:Windows8Resource ResourceKey=MainBrush}" StrokeThickness="2" Width="10" Height="10"/>
                                    </telerik:RadButton>
                                </StackPanel>
                            </Border>
                        </Grid>
                        <Border x:Name="ContentOuterBorder" Grid.Row="1" Margin="{TemplateBinding BorderThickness}" Background="Yellow">
                            <ContentPresenter x:Name="ContentElement" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        </Border>
                    </Grid>
                </Border>
            </Grid>
        </ControlTemplate>
     
        <Style x:Key="RadWindowStyle" TargetType="telerikNavigation:RadWindow">
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Background" Value="{telerik:Windows8Resource ResourceKey=MainBrush}"/>
            <Setter Property="BorderBrush" Value="{telerik:Windows8Resource ResourceKey=BasicBrush}"/>
            <Setter Property="BorderThickness" Value="2 0 2 2"/>
            <Setter Property="BorderBackground" Value="{StaticResource WindowBorderBackground}"/>
            <Setter Property="ModalBackground" Value="{StaticResource WindowModalBackground}"/>
            <Setter Property="MinHeight" Value="32"/>
            <Setter Property="MinWidth" Value="100"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Header" Value="RadWindow"/>
            <Setter Property="WindowStartupLocation" Value="Manual"/>
            <Setter Property="WindowState" Value="Normal"/>
            <Setter Property="Template" Value="{StaticResource RadWindowTemplate}"/>
            <Setter Property="CaptionHeight" Value="28"/>
            <Setter Property="ResizeBorder" Value="4"/>
            <Setter Property="TabNavigation" Value="Cycle"/>
            <Setter Property="animation:AnimationManager.AnimationSelector">
                <Setter.Value>
                    <animation:AnimationSelector>
                        <animation:AnimationGroup AnimationName="Show">
                            <animation:FadeAnimation Direction="In" TargetElementName="LayoutRoot">
                                <animation:FadeAnimation.Easing>
                                    <QuarticEase EasingMode="EaseOut"/>
                                </animation:FadeAnimation.Easing>
                            </animation:FadeAnimation>
                            <animation:ScaleAnimation Direction="In" TargetElementName="LayoutRoot" MinScale="0.9">
                                <animation:ScaleAnimation.Easing>
                                    <QuarticEase EasingMode="EaseOut"/>
                                </animation:ScaleAnimation.Easing>
                            </animation:ScaleAnimation>
                        </animation:AnimationGroup>
                        <animation:AnimationGroup AnimationName="Hide">
                            <animation:FadeAnimation Direction="Out" TargetElementName="LayoutRoot">
                                <animation:FadeAnimation.Easing>
                                    <QuarticEase EasingMode="EaseOut"/>
                                </animation:FadeAnimation.Easing>
                            </animation:FadeAnimation>
                            <animation:ScaleAnimation Direction="Out" TargetElementName="LayoutRoot" MinScale="0.9">
                                <animation:ScaleAnimation.Easing>
                                    <QuarticEase EasingMode="EaseIn"/>
                                </animation:ScaleAnimation.Easing>
                            </animation:ScaleAnimation>
                        </animation:AnimationGroup>
                    </animation:AnimationSelector>
                </Setter.Value>
            </Setter>
        </Style>
     
        <!--<Style TargetType="telerikNavigation:RadWindow" BasedOn="{StaticResource RadWindowStyle}" />-->
        <Style TargetType="telerik:RadWindow" BasedOn="{StaticResource RadWindowStyle}" />
        <Style TargetType="Thumb" BasedOn="{StaticResource WindowResizeThumbStyle}" />
     
     
    </ResourceDictionary>


    ...........

    ..........
  2. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 28 Aug 2014 in reply to kity Link to this post

    I find this post with the same problem here:
    http://www.telerik.com/forums/radwindow-styles-not-being-applied

    I do it that way but still style not want to applied.
  3. DevCraft banner
  4. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 28 Aug 2014 in reply to kity Link to this post

    Explicit is the only one workaround, but it is not good practise.

    <telerik:RadWindow.Resources>
           <ResourceDictionary>
               <ResourceDictionary.MergedDictionaries>
                   <ResourceDictionary Source="/RadGauge;component/Style/RadWindowStyle.xaml" />
                   <telerik:Windows8ResourceDictionary />           
               </ResourceDictionary.MergedDictionaries>
               <Style TargetType="radGauge:ChildWindow1" BasedOn="{StaticResource RadWindowStyle}" />        
           </ResourceDictionary>
       </telerik:RadWindow.Resources>


    ????
Back to Top