This is a migrated thread and some comments may be shown as answers.

MaskedInput Disabled Style

8 Answers 258 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 15 Apr 2011, 02:25 PM
Hi There,

I am trying to apply a different disabled style to the MaskedInput (more specifically MaskedDateTimeInput).  I've done the copy template and such from Blend.

The problem I am having is that the Disabled State doesn't seem to be triggered from the RadMaskedInputBase, which means the DisabledVisual element Visibility property is never set to Visible.

I tested without the custom style, all the Masked Input controls disabled style is different to the other controls (combo, numeric up down, etc..).

I am wonder if this is a bug, or am I missing something..

I've got a temporary work around right now, where I've got the EditorSite to show disabled (not a white background), but not where the clear button is (still white background).  I've done this by adding a Disabled VisualState to the control template of PreviewInputTextBox and adding an extra border where the ReadOnlyVisualElement is.  This only shows 2/3's grey.

Please advise soon.

Sam

8 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 20 Apr 2011, 03:06 PM
Hello Sam,

Could you please provide us with the custom style that you are using so that we can test this on our end?

Thank you.

Kind regards,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sam
Top achievements
Rank 1
answered on 20 Apr 2011, 04:22 PM
Hi Alex,

Its essentially left untouched from when I clicked on Edit a Copy in Expression Blend.

The only thing I have changed, is x:Name="DisabledVisual" where I've also added Background="Black" (for demonstration purposes).  If I changed the visibility to Visible, than it shows, and I see that in the VisualState x:Name="Disabled" it changes this element to Visible.  So my problem is that it doesn't seem to ever trigger this state.

It seems to me it happens to all the MaskedInput Controls, because none of them goes to another style.

I've also attached a screen shot of how it looks like by default compared to the other controls.  This is before or after I apply the styles.

I am using version 2011.1.0315.1040

Sam

<
ResourceDictionary
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:Telerik_Windows_Controls_MaskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:Telerik_Windows_Controls_Chromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls">
    <SolidColorBrush x:Key="ControlForeground_Normal" Color="#FF000000"/>
    <!-- Resource dictionary entries should be defined here. -->
    <SolidColorBrush x:Key="ControlOuterBorder_Normal" Color="#FF848484"/>
    <SolidColorBrush x:Key="TextBoxBackground" Color="#FFFFFFFF"/>
    <SolidColorBrush x:Key="TextBoxBackground_ReadOnly" Color="#5EC9C9C9"/>
    <telerik:Office_BlackTheme x:Key="Theme"/>
    <Style x:Key="TextBoxStyle" TargetType="Telerik_Windows_Controls_MaskedInput:PreviewInputTextBox">
        <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}"/>
        <Setter Property="MinHeight" Value="22"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Telerik_Windows_Controls_MaskedInput:PreviewInputTextBox">
                    <Grid x:Name="RootElement">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="ReadOnly">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ReadOnlyVisualElement"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid Background="{TemplateBinding Background}" Height="{TemplateBinding Height}">
                            <Border x:Name="ReadOnlyVisualElement" Background="{StaticResource TextBoxBackground_ReadOnly}" Opacity="0"/>
                            <Border BorderBrush="Transparent" BorderThickness="1" Margin="-1">
                                <ScrollViewer x:Name="ContentElement" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" telerik:StyleManager.Theme="{StaticResource Theme}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <SolidColorBrush x:Key="ControlBackground_Disabled" Color="#FFE0E0E0"/>
    <SolidColorBrush x:Key="ControlOuterBorder_Disabled" Color="#FF989898"/>
    <SolidColorBrush x:Key="ControlElement_Disabled" Color="#FF8D8D8D"/>
    <ControlTemplate x:Key="ClearButtonTemplate" TargetType="telerik:RadButton">
        <Border x:Name="ButtonBorder" BorderBrush="White" BorderThickness="1" CornerRadius="15">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF8F2121" Offset="1"/>
                    <GradientStop Color="#FFEB4545"/>
                </LinearGradientBrush>
            </Border.Background>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0:0:0.2"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ColorAnimation Duration="0" To="#FF410404" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ButtonBorder"/>
                            <ColorAnimation Duration="0" To="#FFE23737" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ButtonBorder"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <ColorAnimation Duration="0" To="#FFE23737" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ButtonBorder"/>
                            <ColorAnimation Duration="0" To="#FF410404" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ButtonBorder"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBorder">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ControlBackground_Disabled}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBorder">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ControlOuterBorder_Disabled}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="Path">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ControlElement_Disabled}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="FocusStates">
                    <VisualState x:Name="Focused"/>
                    <VisualState x:Name="Unfocused"/>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Path x:Name="Path" Data="M5,0.5 L6,0.5 6,5 10.5,5 10.5,6 6,6 6,10.5 5,10.5 5,6 0.5,6 0.5,5 5,5 z" Margin="4" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Stroke="White">
                <Path.RenderTransform>
                    <RotateTransform Angle="-45"/>
                </Path.RenderTransform>
            </Path>
        </Border>
    </ControlTemplate>
    <Style x:Key="ClearButtonStyle" TargetType="telerik:RadButton">
        <Setter Property="Template" Value="{StaticResource ClearButtonTemplate}"/>
        <Setter Property="Width" Value="19"/>
        <Setter Property="Height" Value="19"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Margin" Value="0,0,3,0"/>
        <Setter Property="Cursor" Value="Hand"/>
    </Style>
    <Telerik_Windows_Controls_MaskedInput:HorizontalContentAlignmentToTextAlignmentConverter x:Key="conv"/>
    <telerik:BooleanToVisibilityConverter x:Key="boolToVisConverter"/>
    <CornerRadius x:Key="ControlOuterBorder_CornerRadius">1</CornerRadius>
    <SolidColorBrush x:Key="ControlOuterBorder_Focused" Color="#FFFFC92B"/>
    <SolidColorBrush x:Key="ControlForeground_Disabled" Color="#FF8D8D8D"/>
    <SolidColorBrush x:Key="ControlOuterBorder_MouseOver" Color="#FFFFC92B"/>
    <Style x:Key="RadMaskedInputBaseStyle" TargetType="telerik:RadMaskedInputBase">
        <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder_Normal}"/>
        <Setter Property="Background" Value="{StaticResource TextBoxBackground}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="TextBoxStyle" Value="{StaticResource TextBoxStyle}"/>
        <Setter Property="ClearButtonStyle" Value="{StaticResource ClearButtonStyle}"/>
        <Setter Property="MinHeight" Value="22"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Padding" Value="2 0 0 0"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="IsReadOnly" Value="False"/>
        <Setter Property="TextMode" Value="MaskedText"/>
        <Setter Property="ErrorMessageTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Foreground="White" FontSize="12" Text="{Binding}"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadMaskedInputBase">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="ErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>False</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClearButton">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ReadOnly">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="GridContainer">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxBackground_ReadOnly}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisabledVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="EditorSite">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ControlForeground_Disabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="DisplayText">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ControlForeground_Disabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ControlForeground_Disabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Border">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ControlOuterBorder_MouseOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClearButton">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisplayTextContent">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusedVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="NotFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisplayTextContent">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid"/>
                                <VisualState x:Name="InValidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="ErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>True</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="InValidNotFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="ErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>False</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ContentStates">
                                <VisualState x:Name="NotEmpty"/>
                                <VisualState x:Name="Empty">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="ErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>False</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="EmptyContent">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}">
                            <Grid x:Name="GridContainer">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Telerik_Windows_Controls_MaskedInput:PreviewInputTextBox x:Name="EditorSite" AcceptsReturn="True" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" Height="{TemplateBinding Height}" IsTabStop="True" IsReadOnly="{TemplateBinding IsReadOnly}" IsEnabled="{TemplateBinding IsEnabled}" Padding="{TemplateBinding Padding}" Style="{TemplateBinding TextBoxStyle}" TextAlignment="{Binding HorizontalContentAlignment, Converter={StaticResource conv}, RelativeSource={RelativeSource Mode=TemplatedParent}}" TabIndex="{TemplateBinding TabIndex}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <Border x:Name="DisplayTextContent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" IsHitTestVisible="False" Visibility="Collapsed">
                                    <Telerik_Windows_Controls_MaskedInput:PreviewInputTextBox x:Name="DisplayText" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" Height="{TemplateBinding Height}" IsTabStop="False" IsReadOnly="{TemplateBinding IsReadOnly}" IsEnabled="{TemplateBinding IsEnabled}" Padding="{TemplateBinding Padding}" Style="{TemplateBinding TextBoxStyle}" TextAlignment="{Binding HorizontalContentAlignment, Converter={StaticResource conv}, RelativeSource={RelativeSource Mode=TemplatedParent}}" Text="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Mode=TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                </Border>
                                <Border x:Name="EmptyContent" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsHitTestVisible="False" Padding="5,0,0,0" Visibility="Collapsed">
                                    <ContentControl x:Name="Content" ContentTemplate="{TemplateBinding EmptyContentTemplate}" Content="{TemplateBinding EmptyContent}" Foreground="{TemplateBinding Foreground}" FontStyle="Italic" HorizontalAlignment="Stretch" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="Stretch" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                </Border>
                                <telerik:RadButton x:Name="ClearButton" Grid.Column="1" Command="{TemplateBinding ClearCommand}" IsTabStop="False" IsEnabled="{TemplateBinding IsEnabled}" Opacity="0" Style="{TemplateBinding ClearButtonStyle}" Visibility="{Binding IsClearButtonVisible, Converter={StaticResource boolToVisConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
                            </Grid>
                        </Border>
                        <Border x:Name="FocusedVisual" BorderBrush="{StaticResource ControlOuterBorder_Focused}" BorderThickness="1" CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" Visibility="Collapsed"/>
                        <Telerik_Windows_Controls_Chromes:ValidationTooltip x:Name="ErrorElement" TooltipPlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" telerik:StyleManager.Theme="{StaticResource Theme}" TooltipContent="{TemplateBinding DisplayErrorMessage}" TooltipContentTemplate="{TemplateBinding ErrorMessageTemplate}" Visibility="Collapsed"/>
                        <Border x:Name="DisabledVisual" BorderBrush="{StaticResource ControlOuterBorder_Disabled}" BorderThickness="1" Background="Black" CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" Visibility="Collapsed"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style BasedOn="{StaticResource RadMaskedInputBaseStyle}" TargetType="telerik:RadMaskedNumericInput">
        <Setter Property="InputBehavior" Value="Insert"/>
        <Setter Property="Mask" Value="#9.2"/>
        <Setter Property="HorizontalContentAlignment" Value="Right"/>
    </Style>
</ResourceDictionary>

0
Alex Fidanov
Telerik team
answered on 26 Apr 2011, 07:44 AM
Hi Sam,

I copy-pasted the style that you provided and it works perfectly (for the RadMaskedNumericInput only). This is because you have created a default style only for it. The base style would not be applied to any other control, as it has a x:Key. If you want to apply this style to all of the control, you would have to create a default style for them and base it on the base style. For example:

<Style BasedOn="{StaticResource RadMaskedInputBaseStyle}" TargetType="telerik:RadMaskedDateTimeInput" >
</Style>
Please let me know if you still have issues with this matter.

Best wishes,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sam
Top achievements
Rank 1
answered on 26 Apr 2011, 08:26 AM
Hi Alex,

It didn't matter which control out of the four I created the style for, they all behaved the same, you can see in my screen shot.  I am creating them for all four.  I am aware of the TargetType of the style,  I have one for each of the controls, and probably copied the wrong one as I was copying them, you can see from the screen shot, where I have all four controls, none of them change to the disabled style.  What you see in the screen shot is the Disabled style applied.

Can you tell me the version your using? Also are you setting the IsDisabled property to True/False?

I am using version 2011.1.0315.1040

I am testing this with all four controls with a different TargetType and none of them changes to the Disabled Style.  I am also sure that the style is the Default style of the controls because if I changed the Visibility="Visible" then it shows up as it should.

Just to be clear, I have linked it in the App.xaml as well.  For this one, I am only showing the NumericInput, but the same thing happens for all other controls.

<Application
    x:Class="Demo.App">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MaskedNumericInput.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>   
</Application>


Sam
0
Alex Fidanov
Telerik team
answered on 26 Apr 2011, 08:40 AM
Hi Sam,

 I am using the same version. I am not sure why the style is not being applied on your end. Perhaps, another style is taking precedence over this one. I have attached the project that I am using to test this and a screenshot of what I am seeing.

Best wishes,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sam
Top achievements
Rank 1
answered on 27 Apr 2011, 07:27 AM
Hi Alex,

I finally understand whats going on, it's to do with programmatic changing of IsEnabled when it doesn't work.

I've tried changing through the code behind and ViewModel.  Both methods doesn't cause the style to change.

In the screen shot I've attached, there are four extra buttons which control the IsEnabled of the controls on screen.  I've also added a DateTimePicker to show that it works programmatically.  

What you can see here is the DateTimePicker changes correctly while the MaskedInput controls remain disabled (initial state).

Xaml
<UserControl x:Class="SilverlightApplication66.MainPage"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="400"
             xmlns:local="clr-namespace:SilverlightApplication66">
    <UserControl.Resources>
        <local:MainPageViewModel x:Key="ViewModel" />
    </UserControl.Resources>
    <UserControl.DataContext>
        <Binding Source="{StaticResource ViewModel}" />
    </UserControl.DataContext>
    <Grid x:Name="LayoutRoot"
          Background="White"
          xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
        <StackPanel>
            <telerik:RadMaskedDateTimeInput Name="DateTimeInput"
                                            IsEnabled="{Binding IsEnabled, Mode=TwoWay, Source={StaticResource ViewModel}}" />
            <telerik:RadMaskedNumericInput Name="NumericInput"
                                           IsEnabled="{Binding IsEnabled, Mode=TwoWay, Source={StaticResource ViewModel}}" />
            <telerik:RadMaskedCurrencyInput Name="CurrencyInput"
                                            IsEnabled="{Binding IsEnabled, Mode=TwoWay, Source={StaticResource ViewModel}}" />
            <telerik:RadMaskedTextInput Name="TextInput"
                                        IsEnabled="{Binding IsEnabled, Mode=TwoWay, Source={StaticResource ViewModel}}" />
            <telerik:RadDateTimePicker Name="DateTimePicker"
                                       IsEnabled="{Binding IsEnabled, Mode=TwoWay, Source={StaticResource ViewModel}}" />
            <Button Content="Enable (ViewModel)"
                    Command="{Binding EnableCommand}" />
            <Button Content="Disable (ViewModel)"
                    Command="{Binding DisableCommand}" />
            <Button Click="Button_Click"
                    Content="Enable (Code Behind)" />
            <Button Click="Button_Click"
                    Content="Disable (Code Behind)" />
        </StackPanel>
    </Grid>
</UserControl>

Code Behind:
private void Button_Click(object sender, RoutedEventArgs e) {
    DateTimeInput.IsEnabled = !DateTimeInput.IsEnabled;
    NumericInput.IsEnabled = !NumericInput.IsEnabled;
    CurrencyInput.IsEnabled = !CurrencyInput.IsEnabled;
    TextInput.IsEnabled = !TextInput.IsEnabled;
    DateTimePicker.IsEnabled = !DateTimePicker.IsEnabled;
}

ViewModel:
public class MainPageViewModel : INotifyPropertyChanged {
        private ICommand _disableCommand;
        private ICommand _enabledCommand;
        private bool _isEnabled;
        public event PropertyChangedEventHandler PropertyChanged;
 
        public ICommand DisableCommand {
            get {
                if (_disableCommand == null) {
                    _disableCommand = new DelegateCommand((o) => {
                        IsEnabled = false;
                    });
                }
                return _disableCommand;
            }
        }
 
        public ICommand EnableCommand {
            get {
                if (_enabledCommand == null) {
                    _enabledCommand = new DelegateCommand((o) => {
                        IsEnabled = true;
                    });
                }
                return _enabledCommand;
            }
        }
 
        public bool IsEnabled {
            get {
                return _isEnabled;
            }
            set {
                _isEnabled = value;
                RaisePropertyChanged("IsEnabled");
            }
        }
 
        private void RaisePropertyChanged(string propertyName) {
            if (PropertyChanged == null) {
                return;
            }
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

Sam

0
Accepted
Alex Fidanov
Telerik team
answered on 27 Apr 2011, 07:34 AM
Hi Sam,

We did resolve an issue with IsEnabled property being changed programatically. Please re-test this with a later internal build or the service pack. This should be working correctly with the new version.

Kind regards,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sam
Top achievements
Rank 1
answered on 02 May 2011, 02:34 PM
Hi Alex,

after installing version 2011.1.419.1040 this problem is now fixed.

thanks

Sam
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Sam
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Sam
Top achievements
Rank 1
Share this question
or