I ran into a bug with the RadSlider that tripped me up for a few
hours. There's an easy workaround, but I figured that this is the sort
of thing that you'd want to know about so you could fix it.
Synopsis:
When a RadSlider is databound to an object, if the value that is bound to the Minimum property is set prior to setting the object that is bound to the Maximum value then your application will terminate with a StackOverflowException.
What ends up happening, (as far as I can tell), is that internally the API sees that Minimum has been set to X and so reacts by setting SelectionStart = Minimum. The API then notices that SelectionStart > SelectionEnd and so sets SelectionStart to 0. This cycle repeats until the stack is blown: Selection start goes back to X, then 0, then X, then 0, then.....
Reproduction case:
I created a simple little WPF app to reproduce this problem.
XAML:
C#:
You can look at your console output to see the problem as it happens.
Workaround:
Setting Maximum prior to Minimum completely avoids this glitch, which is fine for now. Hopefully you folks can patch this up so that others don't need to spend the time scratching their heads and trying to figure out what went horribly wrong with their code. =)
Synopsis:
When a RadSlider is databound to an object, if the value that is bound to the Minimum property is set prior to setting the object that is bound to the Maximum value then your application will terminate with a StackOverflowException.
What ends up happening, (as far as I can tell), is that internally the API sees that Minimum has been set to X and so reacts by setting SelectionStart = Minimum. The API then notices that SelectionStart > SelectionEnd and so sets SelectionStart to 0. This cycle repeats until the stack is blown: Selection start goes back to X, then 0, then X, then 0, then.....
Reproduction case:
I created a simple little WPF app to reproduce this problem.
XAML:
<Window x:Class="TelerikStackoverflowRepro.MainWindow" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" Title="MainWindow" Height="350" Width="525"> |
<Grid> |
<telerik:RadSlider Name="NumericSlider" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" |
SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}" SelectionStart="{Binding SelectionStart, Mode=TwoWay}" IsSelectionRangeEnabled="True"/> |
</Grid> |
</Window> |
C#:
using System; |
using System.Windows; |
namespace TelerikStackoverflowRepro |
{ |
public partial class MainWindow : Window |
{ |
public MainWindow() |
{ |
InitializeComponent(); |
var data = new SelectionData(); |
data.Initialize(); |
this.DataContext = data; |
} |
} |
public class SelectionData |
{ |
private int min; |
private int max; |
private int selectionStart; |
private int selectionEnd; |
public int Minimum |
{ |
get |
{ |
return min; |
} |
set |
{ |
min = value; |
Console.WriteLine("Minimum set to " + min); |
} |
} |
public int Maximum |
{ |
get |
{ |
return max; |
} |
set |
{ |
max = value; |
Console.WriteLine("Maximum set to " + max); |
} |
} |
public int SelectionStart |
{ |
get |
{ |
return selectionStart; |
} |
set |
{ |
selectionStart = value; |
Console.WriteLine("SelectionStart set to " + selectionStart); |
} |
} |
public int SelectionEnd |
{ |
get |
{ |
return selectionEnd; |
} |
set |
{ |
selectionEnd = value; |
Console.WriteLine("SelectionEnd set to " + selectionEnd); |
} |
} |
public void Initialize() |
{ |
Minimum = 6; |
Maximum = 12; |
} |
} |
} |
You can look at your console output to see the problem as it happens.
Workaround:
Setting Maximum prior to Minimum completely avoids this glitch, which is fine for now. Hopefully you folks can patch this up so that others don't need to spend the time scratching their heads and trying to figure out what went horribly wrong with their code. =)