Another problem with RadSlider and negative values?

9 posts, 1 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 21 Dec 2010 Link to this post

    Hello,

    I have found another problem with the RadSlider and negative values.  In a previous post, it was reccomended that I TwoWay bind my properties which seems to have fixed most cases except for one...  I have tried TwoWay binding and reordering the properties and cannot solve this one... 

    Notice that the "Value2" property is set to "-3".  And that the "Slider.SelectionEnd" property is showing "0".  As soon as you manipulate the slider it seems to fix itself but obviously this is not desirable...

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    x:Class="SilverlightApplication140.MainPage"
                    Width="640" Height="480"
    >
        <StackPanel Orientation="Vertical" Background="White">
            <telerik:RadSlider
                x:Name="rs"
                Margin="5,13,5,13"
                IsSelectionRangeEnabled="True"
                MinimumRangeSpan="0"
                TickPlacement="None"
                TickFrequency="1"
                IsSnapToTickEnabled="True"
                SelectionStart="{Binding Value1, Mode=TwoWay}"
                SelectionEnd="{Binding Value2, Mode=TwoWay}"
                Maximum="{Binding Max, Mode=TwoWay}"
                Minimum="{Binding Min, Mode=TwoWay}"
            />
            <TextBlock Text="{Binding Min, StringFormat='DataObject(Min)=\{0\}'}" />
            <TextBlock Text="{Binding Max, StringFormat='DataObject(Max)=\{0\}'}" />
            <TextBlock Text="{Binding Value1, StringFormat='DataObject(Value1)=\{0\}'}" />
            <TextBlock Text="{Binding Value2, StringFormat='DataObject(Value2)=\{0\}'}" />
            <TextBlock Text="{Binding ElementName=rs, Path=Minimum, StringFormat='Slider(Minimum)=\{0\}'}" />
            <TextBlock Text="{Binding ElementName=rs, Path=Maximum, StringFormat='Slider(Maximum)=\{0\}'}" />
            <TextBlock Text="{Binding ElementName=rs, Path=SelectionStart, StringFormat='Slider(SelectionStart)=\{0\}'}" />
            <TextBlock Text="{Binding ElementName=rs, Path=SelectionEnd, StringFormat='Slider(SelectionEnd)=\{0\}'}" />
        </StackPanel>
    </UserControl>
    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;
      
    namespace SilverlightApplication140
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                // Required to initialize variables
                InitializeComponent();
                  
                MyDataObject mdo = new MyDataObject()
                {
                    Value1 = -25,
                    Value2 = -3,
                    Min = -100,
                    Max = 100,
                };              
                  
                this.DataContext = mdo;
                  
            }
        }
          
          
        public class MyDataObject : System.ComponentModel.INotifyPropertyChanged
        {
            private int _Value1 = 0;
            public int Value1
            {
                get
                {
                    return _Value1;
                }
                set
                {
                    this._Value1 = value;
                    RaisePropertyChanged("Value1");
                }
            }
      
            private int _Value2 = 0;
            public int Value2
            {
                get
                {
                    return _Value2;
                }
                set
                {
                    this._Value2 = value;
                    RaisePropertyChanged("Value2");
                }
            }
              
            private int _Min = 0;
            public int Min
            {
                get
                {
                    return _Min;
                }
                set
                {
                    this._Min = value;
                    RaisePropertyChanged("Min");
                }
            }
      
            private int _Max = 0;
            public int Max
            {
                get
                {
                    return _Max;
                }
                set
                {
                    this._Max = value;
                    RaisePropertyChanged("Max");
                }
            }
              
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
      
            protected void RaisePropertyChanged(string propertyName)
            {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new  System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
              
        }
          
          
          
    }
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Dec 2010 Link to this post

    Hi Rob,

    Unfortunately, you have come up with an issue that is not fixed yet. You can vote for it here.
    Feel free to ask if you need further assistance.

    Kind regards,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 23 Dec 2010 Link to this post

    Do you have any suggestions as to how I can get around this issue in the meantime?  Forcing a layout update or resetting the binding perhaps?   

    Thanks,
    Rob
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 24 Dec 2010 Link to this post

    Hello Rob,

    I prepared a workaround for you that uses the Loaded event of the RadSlider and set the SelectionEnd and SelectionStart like so:
    private void radSlider_Loaded(object sender, RoutedEventArgs e)
            {
                this.radSlider.SelectionEnd = (this.radSlider.DataContext as MyDataObject).Value1;
                this.radSlider.SelectionEnd = (this.radSlider.DataContext as MyDataObject).Value2;
            }
     Please give it a try and let me know if it fits in your scenario or not.

    Kind regards,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  6. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 10 Jan 2011 Link to this post

    I tried this and it seems to work so far.  Thanks for your help.
  7. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 13 Jan 2011 Link to this post

    Unfortunately, this doesn't appear to work.  A little more background about my project might help you out...  We are loading the RadSlider as a way to set tolerances on specific columns in the RadGrid's custom filter popup.  The first time I open the popup, the control loads with all the values smashed against one side.  If I simply close/repopen the popup, everything is fine.  I have tried adding UpdateLayout events, updating my binding at different times and even setting the values so that the control would not "trip" on itself and try to set a value outside the allowable range...

    I've attached a picture of the control as it exists in our app.  I will also attach the custom style we're using and the code I am trying to use to update the values...

    The scenarios that I am trying to satisfy are:
    - Min = 0; Max = 100;
    - Min = 100; Max = 300;
    - Min = -100; Max = 100; SelectionStart and SelectionEnd are both initially < 0.
    - Min = -100; Max = 100; SelectionStart and SelectionEnd are both initially > 0.

    Is this a bug here or am I doing something wrong?  It would seem to be that the control is simply not behaving properly...

    <Style x:Key="rs_style" TargetType="telerik:RadSlider">
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="Orientation" Value="Horizontal"/>
            <Setter Property="IsEnabled" Value="True"/>
            <Setter Property="HandlesVisibility" Value="Collapsed"/>
            <Setter Property="IsMouseWheelEnabled" Value="False"/>
            <Setter Property="EnableSideTicks" Value="False"/>
            <Setter Property="Delay" Value="250"/>
            <Setter Property="RepeatInterval" Value="250"/>
            <Setter Property="StepAction" Value="ChangeRange"/>
            <Setter Property="ThumbVisibility" Value="Visible"/>
            <Setter Property="MinimumRangeSpan" Value="0.0"/>
            <Setter Property="TickPlacement" Value="None"/>
            <Setter Property="TickFrequency" Value="1"/>
            <Setter Property="IsSnapToTickEnabled" Value="True"/>
            <Setter Property="IsSelectionRangeEnabled" Value="True"/>
      
            <!-- "Background" is used for the "Left Region" -->
            <Setter Property="Background" Value="Red" />
              
            <!-- "Foreground" is used for the "Right Region" -->
            <Setter Property="Foreground" Value="Green" />
      
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerik:RadSlider">
                        <Grid x:Name="LayoutRoot">
      
                            <Grid.Resources>
      
                                <DataTemplate x:Key="HorizontalTickTemplate">
                                    <Grid x:Name="RootElement" ToolTipService.ToolTip="{Binding}">
                                        <Rectangle Fill="#FF000000" Height="5" Width="1"/>
                                    </Grid>
                                </DataTemplate>
      
                                <DataTemplate x:Key="VerticalTickTemplate">
                                    <Grid x:Name="RootElement" ToolTipService.ToolTip="{Binding}">
                                        <Rectangle Fill="#FF000000" Height="1" Width="5"/>
                                    </Grid>
                                </DataTemplate>
      
                                <ControlTemplate x:Key="TickBarTemplate" TargetType="telerik:RadTickBar">
                                    <Canvas x:Name="LayoutRoot" Background="Transparent"/>
                                </ControlTemplate>
      
                                <ControlTemplate x:Key="HorizontalThumbTemplate" TargetType="Thumb">
                                    <Grid Height="28" Width="9" Cursor="Hand" Background="Transparent">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="InnerShell_Fill" Storyboard.TargetProperty="Opacity" Duration="0" To="0.695" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="InnerShell_Fill" Storyboard.TargetProperty="Opacity" Duration="0" To="0" />
                                                        <ColorAnimation Storyboard.TargetName="OuterShell" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Duration="0" To="#FF1985DD" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled">
                                                    <Storyboard>
                                                        <ColorAnimation Storyboard.TargetName="OuterShell" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Duration="0" To="#FF848484" />
                                                        <ColorAnimation Storyboard.TargetName="InnerShell_Fill1" Storyboard.TargetProperty="(GradientStop.Color)" Duration="0" To="#FFFFFFFF" />
                                                        <ColorAnimation Storyboard.TargetName="InnerShell_Fill2" Storyboard.TargetProperty="(GradientStop.Color)" Duration="0" To="#FF848484" />
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Path x:Name="OuterShell" Grid.Row="0" Grid.Column="0" Height="9" Width="9" Stretch="Fill" VerticalAlignment="Top" Data="M0,0 L2,0 L2,1 L1,2 L0,1 z" Stroke="#FF799FBF" Fill="#FF1985DD" />
                                        <Path x:Name="InnerShell" Grid.Row="0" Grid.Column="0" Height="7" Width="7" Stretch="Fill" VerticalAlignment="Top" Data="M0,0 L2,0 L2,1 L1,2 L0,1 z" Stroke="#FFFFFFFF" Margin="0,1,0,1">
                                            <Path.Fill>
                                                <RadialGradientBrush x:Name="InnerShell_Fill" RadiusX="1" RadiusY="1" Center="3.5,3" GradientOrigin="3.5,3" MappingMode="Absolute">
                                                    <GradientStop x:Name="InnerShell_Fill1" Color="#FF799FBF" Offset="0.104"/>
                                                    <GradientStop x:Name="InnerShell_Fill2" Color="#FFC9DBF0" Offset="0.53"/>
                                                </RadialGradientBrush>
                                            </Path.Fill>
                                        </Path>
                                        <Rectangle x:Name="Separator" Width="1" Height="12" VerticalAlignment="Top" Margin="0,11,0,0">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                                    <GradientStop Color="#FF799FBF" />
                                                    <GradientStop Color="#FF000000" Offset="0.8" />
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                    </Grid>
                                </ControlTemplate>
      
                                <ControlTemplate x:Key="HorizontalRangeSelectionThumbTemplate" TargetType="Thumb">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver" />
                                                <VisualState x:Name="Pressed" />
                                                <VisualState x:Name="Disabled" />
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                    </Grid>
                                </ControlTemplate>
      
                                <ControlTemplate x:Key="VerticalThumbTemplate" TargetType="Thumb">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver" />
                                                <VisualState x:Name="Pressed" />
                                                <VisualState x:Name="Disabled" />
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                    </Grid>
                                </ControlTemplate>
      
                                <ControlTemplate x:Key="VerticalRangeSelectionThumbTemplate" TargetType="Thumb">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver" />
                                                <VisualState x:Name="Pressed" />
                                                <VisualState x:Name="Disabled" />
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                    </Grid>
                                </ControlTemplate>
      
                            </Grid.Resources>
      
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused" />
                                    <VisualState x:Name="Unfocused" />
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ValidationStates">
                                    <VisualState x:Name="Valid"/>
                                    <VisualState x:Name="InvalidUnfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="InvalidFocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="validationTooltip">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.1">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <System:Boolean>True</System:Boolean>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
      
                            <Grid>
      
                                <!-- Horizontal Templates -->
                                <Grid x:Name="HorizontalTemplate">
      
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
      
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
      
                                    <!-- Horizontal Tick Bars -->
                                    <telerik:RadTickBar x:Name="TopTickBar" Grid.Row="0" Grid.Column="1" EnableSideTicks="{TemplateBinding EnableSideTicks}" IsTabStop="False" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Maximum="{TemplateBinding Maximum}" Minimum="{TemplateBinding Minimum}" MinHeight="6" Orientation="{TemplateBinding Orientation}" Placement="Top" Ticks="{TemplateBinding Ticks}" TickTemplateSelector="{TemplateBinding TickTemplateSelector}" TickTemplate="{TemplateBinding TickTemplate}" TickFrequency="{TemplateBinding TickFrequency}" Template="{StaticResource TickBarTemplate}"/>
                                    <telerik:RadTickBar x:Name="BottomTickBar" Grid.Row="2" Grid.Column="1" EnableSideTicks="{TemplateBinding EnableSideTicks}" IsTabStop="False" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Maximum="{TemplateBinding Maximum}" Minimum="{TemplateBinding Minimum}" MinHeight="6" Orientation="{TemplateBinding Orientation}" Placement="Bottom" Ticks="{TemplateBinding Ticks}" TickTemplateSelector="{TemplateBinding TickTemplateSelector}" TickTemplate="{TemplateBinding TickTemplate}" TickFrequency="{TemplateBinding TickFrequency}" Template="{StaticResource TickBarTemplate}"/>
      
                                    <!-- Horizontal - Single Thumb -->
                                    <Grid x:Name="HorizontalSingleThumbTemplate" Grid.Column="1" Grid.Row="1">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="1*" />
                                            <RowDefinition Height="11" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="1*"/>
                                        </Grid.ColumnDefinitions>
      
                                        <!-- Left Track -->
                                        <Rectangle x:Name="HorizontalSingle_LeftTrack" Grid.Row="0" Grid.Column="0" StrokeThickness="0" Height="9" VerticalAlignment="Center" Margin="0,8,-5,0">
                                        </Rectangle>
      
                                        <!-- Right Track -->
                                        <Rectangle x:Name="HorizontalSingle_RightTrack" Grid.Row="0" Grid.Column="2" StrokeThickness="0" Height="9" VerticalAlignment="Center" Margin="-4,8,0,0">
                                        </Rectangle>
      
                                        <!-- Display Value -->
                                        <TextBlock Grid.Row="1" Grid.Column="1" Foreground="#FF7A7A7A" FontFamily="Century Gothic" FontSize="8.5" Margin="-6,0,-6,0" HorizontalAlignment="Center" Text="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=\{0:N0\}}" />
      
                                        <Rectangle x:Name="HorizontalSingleLargeDecrease" Fill="Transparent" Opacity="0" VerticalAlignment="Stretch"/>
                                        <Thumb x:Name="HorizontalSingleThumb" Grid.Column="1" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource HorizontalThumbTemplate}" Visibility="{TemplateBinding ThumbVisibility}" ToolTipService.ToolTip="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=\{0:N0\}}" />
                                        <Rectangle x:Name="HorizontalSingleLargeIncrease" Grid.Column="2" Fill="Transparent" Opacity="0" VerticalAlignment="Stretch"/>
      
                                    </Grid>
      
                                    <!-- Horizontal - Dual Thumb -->
                                    <Grid x:Name="HorizontalRangeTemplate" Grid.Column="1" Grid.Row="1">
      
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="1*" />
                                            <RowDefinition Height="11" />
                                        </Grid.RowDefinitions>
      
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="1*"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
      
                                        <!-- Left Track -->
                                        <Rectangle x:Name="HorizontalDual_LeftTrack" Grid.Row="0" Grid.Column="0" StrokeThickness="0" Height="9" VerticalAlignment="Center" Margin="0,8,-5,0" Fill="{TemplateBinding Background}">
                                        </Rectangle>
      
                                        <!-- Middle Track -->
                                        <Rectangle x:Name="HorizontalDual_MiddleTrack" Grid.Row="0" Grid.Column="2" StrokeThickness="0" Height="9" VerticalAlignment="Center" Margin="-4,8,-5,0">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="#FFF0E663" Offset="0.13"/>
                                                    <GradientStop Color="#FFAB9C00" Offset="0.917"/>
                                                    <GradientStop Color="#FFE3D75D" Offset="0.065"/>
                                                    <GradientStop Color="#FFD8C600" Offset="0.6"/>
                                                    <GradientStop Color="#FFEADD4B" Offset="0.339"/>
                                                    <GradientStop Color="#FFD3C100" Offset="0.665"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
      
                                        <!-- Right Track -->
                                        <Rectangle x:Name="HorizontalDual_RightTrack" Grid.Row="0" Grid.Column="4" StrokeThickness="0" Height="9" VerticalAlignment="Center" Margin="-4,8,0,0" Fill="{TemplateBinding Foreground}">
                                        </Rectangle>
                                        <TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1"
                                                    Foreground="#FF7A7A7A" 
                                                    FontFamily="Century Gothic"
                                                    FontSize="8.5" 
                                                    HorizontalAlignment="Right" Margin="-4,0,-3,0"
                                                    Text="{Binding Path=SelectionStart, RelativeSource={RelativeSource TemplatedParent}, StringFormat='\{0:N0\}'}" />
      
                                        <TextBlock Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="1"
                                                    Foreground="#FF7A7A7A" 
                                                    FontFamily="Century Gothic"
                                                    FontSize="8.5" 
                                                    HorizontalAlignment="Left" Margin="-3,0,-4,0"
                                                    Text="{Binding Path=SelectionEnd, RelativeSource={RelativeSource TemplatedParent}, StringFormat='\{0:N0\}'}" />
      
                                        <Rectangle x:Name="HorizontalRangeLargeDecrease" Grid.Row="0" Grid.Column="0" Fill="Transparent" Opacity="0" />
                                        <Thumb x:Name="HorizontalRangeStartThumb" Grid.Row="0" Grid.Column="1" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource HorizontalThumbTemplate}" Visibility="{TemplateBinding ThumbVisibility}" ToolTipService.ToolTip="{Binding Path=SelectionStart, RelativeSource={RelativeSource TemplatedParent}, StringFormat=\{0:N0\}}" />
                                        <Thumb x:Name="HorizontalRangeMiddleThumb" Grid.Row="0" Grid.Column="2" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource HorizontalRangeSelectionThumbTemplate}" VerticalAlignment="Center" />
                                        <Thumb x:Name="HorizontalRangeEndThumb" Grid.Row="0" Grid.Column="3" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource HorizontalThumbTemplate}" Visibility="{TemplateBinding ThumbVisibility}" ToolTipService.ToolTip="{Binding Path=SelectionEnd, RelativeSource={RelativeSource TemplatedParent}, StringFormat=\{0:N0\}}"/>
                                        <Rectangle x:Name="HorizontalRangeLargeIncrease" Grid.Row="0" Grid.Column="4" Fill="Transparent" Opacity="0" />
                                    </Grid>
      
                                    <!-- Horizontal - Decrease Button -->
                                    <RepeatButton x:Name="HorizontalDecreaseHandle" Delay="{TemplateBinding Delay}" IsEnabled="{TemplateBinding IsEnabled}" Interval="{TemplateBinding RepeatInterval}" Margin="0 0 2 0" Grid.Row="1" Visibility="{TemplateBinding HandlesVisibility}"/>
      
                                    <!-- Horizontal - Increase Button -->
                                    <RepeatButton x:Name="HorizontalIncreaseHandle" Grid.Column="2" Delay="{TemplateBinding Delay}" IsEnabled="{TemplateBinding IsEnabled}" Interval="{TemplateBinding RepeatInterval}" Margin="2 0 0 0" Grid.Row="1" RenderTransformOrigin="0.5,0.5" Visibility="{TemplateBinding HandlesVisibility}" />
      
                                </Grid>
      
                                <!-- Vertical Templates -->
                                <Grid x:Name="VerticalTemplate">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
      
                                    <!-- Vertical - Tick Bars -->
                                    <telerik:RadTickBar x:Name="LeftTickBar" Grid.Column="0" EnableSideTicks="{TemplateBinding EnableSideTicks}" IsTabStop="False" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Maximum="{TemplateBinding Maximum}" MinWidth="6" Minimum="{TemplateBinding Minimum}" Orientation="{TemplateBinding Orientation}" Placement="Left" Grid.Row="1" Ticks="{TemplateBinding Ticks}" TickTemplateSelector="{TemplateBinding TickTemplateSelector}" TickTemplate="{TemplateBinding TickTemplate}" TickFrequency="{TemplateBinding TickFrequency}" Template="{StaticResource TickBarTemplate}"/>
                                    <telerik:RadTickBar x:Name="RightTickBar" Grid.Column="2" EnableSideTicks="{TemplateBinding EnableSideTicks}" IsTabStop="False" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Maximum="{TemplateBinding Maximum}" MinWidth="6" Minimum="{TemplateBinding Minimum}" Orientation="{TemplateBinding Orientation}" Placement="Right" Grid.Row="1" Ticks="{TemplateBinding Ticks}" TickTemplateSelector="{TemplateBinding TickTemplateSelector}" TickTemplate="{TemplateBinding TickTemplate}" TickFrequency="{TemplateBinding TickFrequency}" Template="{StaticResource TickBarTemplate}"/>
      
                                    <!-- Vertical - Single Thumb -->
                                    <Grid x:Name="VerticalSingleThumbTemplate" Grid.Row="1" Grid.Column="1" Width="18">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="1*" />
                                        </Grid.ColumnDefinitions>
                                        <Rectangle x:Name="VerticalSingleLargeDecrease" Grid.Row="2" Grid.Column="0" Cursor="Hand" Fill="Aqua" HorizontalAlignment="Stretch" Opacity="0" />
                                        <Thumb x:Name="VerticalSingleThumb"  Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" Height="8" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource VerticalThumbTemplate}" Visibility="{TemplateBinding ThumbVisibility}" Width="18" />
                                        <Rectangle x:Name="VerticalSingleLargeIncrease" Grid.Row="0" Grid.Column="0" Cursor="Hand" Fill="Aqua" HorizontalAlignment="Stretch" Opacity="0" />
                                    </Grid>
      
                                    <!-- Vertical - Dual Thumb -->
                                    <Grid x:Name="VerticalRangeTemplate" Grid.Column="1" Grid.Row="1" Width="18">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="1*" />
                                        </Grid.ColumnDefinitions>
                                        <Rectangle x:Name="VerticalRangeLargeDecrease" Grid.Row="4" Grid.Column="0" Cursor="Hand" Fill="Transparent" Opacity="0" />
                                        <Thumb x:Name="VerticalRangeStartThumb" Grid.Row="3" HorizontalAlignment="Center" Height="8" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource VerticalThumbTemplate}" Visibility="{TemplateBinding ThumbVisibility}" Width="18" />
                                        <Thumb x:Name="VerticalRangeMiddleThumb" Grid.Row="2"  HorizontalAlignment="Center" IsEnabled="{TemplateBinding IsEnabled}" Template="{StaticResource VerticalRangeSelectionThumbTemplate}" />
                                        <Thumb x:Name="VerticalRangeEndThumb" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Height="8" IsEnabled="{TemplateBinding IsEnabled}"  Template="{StaticResource VerticalThumbTemplate}" Visibility="{TemplateBinding ThumbVisibility}" Width="18" />
                                        <Rectangle x:Name="VerticalRangeLargeIncrease" Grid.Row="0" Grid.Column="0" Cursor="Hand" Fill="Transparent" Opacity="0"  />
                                    </Grid>
      
                                    <!-- Vertical - Decrease Button -->
                                    <RepeatButton x:Name="VerticalDecreaseHandle" Grid.Row="2" Grid.Column="1" Delay="{TemplateBinding Delay}" HorizontalAlignment="Center" IsEnabled="{TemplateBinding IsEnabled}" Interval="{TemplateBinding RepeatInterval}" Visibility="{TemplateBinding HandlesVisibility}" />
      
                                    <!-- Vertical - Increase Button -->
                                    <RepeatButton x:Name="VerticalIncreaseHandle" Grid.Row="0" Grid.Column="1" Delay="{TemplateBinding Delay}" HorizontalAlignment="Center" IsEnabled="{TemplateBinding IsEnabled}" Interval="{TemplateBinding RepeatInterval}" Visibility="{TemplateBinding HandlesVisibility}" />
      
                                </Grid>
                            </Grid>
      
      
                            <Border x:Name="ValidationErrorElement" BorderBrush="#FFDB000C" BorderThickness="1" Visibility="Collapsed">
                                <ToolTipService.ToolTip>
                                    <ToolTip x:Name="validationTooltip" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                        <ToolTip.Template>
                                            <ControlTemplate TargetType="ToolTip">
                                                <Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
                                                    <Grid.RenderTransform>
                                                        <TranslateTransform x:Name="xform" X="-25"/>
                                                    </Grid.RenderTransform>
                                                    <VisualStateManager.VisualStateGroups>
                                                        <VisualStateGroup x:Name="OpenStates">
                                                            <VisualStateGroup.Transitions>
                                                                <VisualTransition GeneratedDuration="0"/>
                                                                <VisualTransition GeneratedDuration="0:0:0.2" To="Open">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
                                                                            <DoubleAnimation.EasingFunction>
                                                                                <BackEase Amplitude=".3" EasingMode="EaseOut"/>
                                                                            </DoubleAnimation.EasingFunction>
                                                                        </DoubleAnimation>
                                                                        <DoubleAnimation Duration="0:0:0.2" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                                                                    </Storyboard>
                                                                </VisualTransition>
                                                            </VisualStateGroup.Transitions>
                                                            <VisualState x:Name="Closed">
                                                                <Storyboard>
                                                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Open">
                                                                <Storyboard>
                                                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform"/>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                                                                </Storyboard>
                                                            </VisualState>
                                                        </VisualStateGroup>
                                                    </VisualStateManager.VisualStateGroups>
                                                    <Border Background="#FFDC000C" >
                                                        <Border.Effect>
                                                            <DropShadowEffect Opacity="0.5" ShadowDepth="3"/>
                                                        </Border.Effect>
                                                    </Border>
                                                    <Border >
                                                        <TextBlock Foreground="White" MaxWidth="250" Margin="8,3,8,3" TextWrapping="Wrap" Text="{Binding (Validation.Errors)[0].ErrorContent}"/>
                                                    </Border>
                                                </Grid>
                                            </ControlTemplate>
                                        </ToolTip.Template>
                                        <ToolTip.Triggers>
                                            <EventTrigger RoutedEvent="Canvas.Loaded">
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="validationTooltip">
                                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                                <DiscreteObjectKeyFrame.Value>
                                                                    <System:Boolean>true</System:Boolean>
                                                                </DiscreteObjectKeyFrame.Value>
                                                            </DiscreteObjectKeyFrame>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger>
                                        </ToolTip.Triggers>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                                <Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12">
                                    <Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="#FFDC000C" Margin="1,3,0,0"/>
                                    <Path Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff" Margin="1,3,0,0"/>
                                </Grid>
                            </Border>
      
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


    void _radslider_Loaded(object sender, RoutedEventArgs e)
    {
         _radslider.IsSelectionRangeEnabled = true;
      
         //Push the "Maximum" out to the right...
         _radslider.Maximum = _vm.Max;
                  
         //Push the "Minimum" out to the left but be careful of the (+100..+300) case...
         if (_vm.Min > 0)
         {
              _radslider.SelectionStart = _vm.Value1;
              _radslider.SelectionEnd = _vm.Value2;
              _radslider.Minimum = _vm.Min;
         }
         else
         {
              _radslider.Minimum = _vm.Min;
              _radslider.SelectionStart = _vm.Value1;
              _radslider.SelectionEnd = _vm.Value2;
         }
    }


  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Jan 2011 Link to this post

    Hello Rob,

    We would highly appreciate if you can send us a runnable code that shows the issue since we are unable to reproduce it using the style and the Loaded event handler method? This way we could investigate in depth and provide you with a better advice. Thank you in advance.

    All the best,
    Petar Mladenov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  9. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 20 Jan 2011 Link to this post

    Hi Petar,

    I have attached a sample project to support ticket 386199.

    Thanks for your help,
    Rob.
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 Jan 2011 Link to this post

    Hi Rob,

    Please accept our apologies for the inconvenience caused. This appears to be a bug in the RadSlider and we logged it in our PITS where you will be soon able to vote for ( Slider: When using ViewModel  to bind SelectionStart and SelectionEnd, you have to rebind twice when the new SlectionStart is greater than the old selectionEnd).  We updated your telerik points accordingly.

    Kind regards,
    Petar Mladenov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top
DevCraft banner