RadMaskedInput IsReadOnly not being set for Control inside Expander

3 posts, 0 answers
  1. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 25 Jan 2012 Link to this post

    Hi there, 

    I have a number of RadMaskedNumericInput and RadMaskedCurrencyInput in an StackPanel.  The StackPanel is part of a form used to edit an entity.  The IsReadOnly of the fields is bound in MVVM Style to a property.  The problem we have is that the fields behave in a strange way sometimes and remain blocked (IsReadOnly = true) although the bound property was changed.  The strange behavior doesn't affect all fields.  

    Here is the View I use

    <UserControl x:Class="SilverlightApplication1.MainPage"
        xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" mc:Ignorable="d"
        d:DesignHeight="300"
        d:DesignWidth="400">
     
        <UserControl.Resources>
            <Style x:Key="NumericInputStyle" TargetType="Controls:RadMaskedNumericInput" >
                <Setter Property="FontSize" Value="16" />
                <Setter Property="Margin" Value="0" />
                <Setter Property="EmptyContent" Value="0,00" />
                <Setter Property="Placeholder" Value=" " />
                <Setter Property="AllowSkipPlaceholders" Value="False" />
                <Setter Property="AutoFillZeros" Value="False" />
                <Setter Property="IsClearButtonVisible" Value="False" />
                <Setter Property="AutoFillNumberGroupSeparators" Value="False" />
                <Setter Property="TextMode" Value="PlainText" />
                <Setter Property="SelectionOnFocus" Value="SelectAll" />
                <Setter Property="Mask" Value="#4.2" />
                <Setter Property="Width" Value="75" />
                <Setter Property="Height" Value="32" />
            </Style>
        </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="White">
            <ScrollViewer>
                <telerik:RadExpander IsExpanded="False" Background="#FFEEEEEE" Foreground="Black" BorderBrush="Black" BorderThickness="1" Width="500" Margin="0,5,0,0">
                    <StackPanel Height="1800">
                        <StackPanel Margin="0,8,0,3" Background="White">
                            <Controls:RadMaskedNumericInput Value="{Binding Path=Value0, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Style="{StaticResource NumericInputStyle}" IsEnabled="{Binding Path=IsEnabled}"></Controls:RadMaskedNumericInput>
                        </StackPanel>
                        <StackPanel Margin="0,8,0,3" Background="White">
                            <Controls:RadMaskedNumericInput Value="{Binding Path=Value1, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Style="{StaticResource NumericInputStyle}" IsEnabled="{Binding Path=IsEnabled}"></Controls:RadMaskedNumericInput>
                        </StackPanel>
                        <StackPanel Margin="0,8,0,3" Background="White">
                            <Controls:RadMaskedNumericInput Value="{Binding Path=Value2, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Style="{StaticResource NumericInputStyle}" IsEnabled="{Binding Path=IsEnabled}"></Controls:RadMaskedNumericInput>
                        </StackPanel>
                        <StackPanel Margin="0,8,0,3" Background="White">
                            <Controls:RadMaskedNumericInput Value="{Binding Path=Value3, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Style="{StaticResource NumericInputStyle}" IsEnabled="{Binding Path=IsEnabled}"></Controls:RadMaskedNumericInput>
                        </StackPanel>
                        <StackPanel Margin="0,8,0,3" Background="White">
                            <Controls:RadMaskedNumericInput Value="{Binding Path=Value4, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Style="{StaticResource NumericInputStyle}" IsEnabled="{Binding Path=IsEnabled}"></Controls:RadMaskedNumericInput>
                        </StackPanel>
                        <Button Content="Change Enabled Status Of RadMaskedNumericImput" Click="Button_Click" />
                    </StackPanel>
                </telerik:RadExpander>
            </ScrollViewer>
        </Grid>
    </UserControl>


    Here is the Code Behind

    using System.Windows;
    using System.Windows.Controls;
     
    namespace SilverlightApplication1
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                DataContext = new ViewModel();
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                ((ViewModel)DataContext).IsEnabled = !((ViewModel)DataContext).IsEnabled;
            }
        }
    }


    And here is the ViewModel

    using System.ComponentModel;
     
    namespace SilverlightApplication1
    {
        public class ViewModel : INotifyPropertyChanged
        {
            public ViewModel()
            {
                Value1 = 2;
                Value2 = (decimal)1.1;
                Value3 = (decimal) 10.4;
                Value4 = (decimal) 245.15;
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
     
            /// <summary>
            /// Raises a PropertyChanged event
            /// </summary>
            protected void OnPropertyChanged(string property)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(property));
                }
            }
     
            private bool _isEnabled;
            public bool IsEnabled
            {
                get { return _isEnabled; }
                set
                {
                    _isEnabled = value;
                    OnPropertyChanged("IsEnabled");
                }
            }
     
            public decimal? Value0 { get; set; }
            public decimal? Value1 { get; set; }
            public decimal? Value2 { get; set; }
            public decimal? Value3 { get; set; }
            public decimal? Value4 { get; set; }
        }
    }


    In order to reproduce the behavior, please do the following:
    - Start project (F5)
    - Expand the expander, you will see 5 RadMaskedNumericInput fields in a StackPanel
    - Press the button titled "Change Enabled Status Of RadMaskedNumericInput"
    - You will see that all five are now enabled and can be edited
    - Set the cursor in the upper most of the fields
    - Use the scroll bar to the right and hide 3 of the fields
    - Set the cursor in the two remaining fields
    - Scroll back to the top and try to set the cursor in the upper most of the fields, it doesn't work
    - Try to set the cursor in the other fields, and some might, others might not work
    - Trying to move using tab functions, but the disabled fields don't show their content once you move there with tab.

    I would really appreciate your help on this, RadMaskedInput fields are really promising, but this problem keeps on poping up on my forms (most implement the RadInputs inside Expanders).

    Best regards and thank you for you help
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 30 Jan 2012 Link to this post

    Hi Klaus,

    We can confirm that in the last release we introduced issues with the IsEnabled state of the RadMaskedInput controls. However these issues are now fixed and I tested your scenario with our latest internal binaries and it works as expected.

    The fix for the issues will be available with the upcoming Q1 2012 release and you'll be able to test it on your side as well. Please let us know if the fix works for you once it's out.

    Greetings,
    Tina Stancheva
    the Telerik team

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

  3. DevCraft banner
  4. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 30 Jan 2012 Link to this post

    Thanks Tina!
Back to Top