I have implemented the "Custom Filter Control" example where you have a slider control in the filter area for "Stadium Capacity". Instead of hard-coding the Maximum to 50000 is there a way to bind it to the maximum value found in the original (not filtered) data set?
Thanks
--tolga
11 Answers, 1 is accepted
Simply replace the declaration for the Maximum property in the SliderFilteringControl class from the example with this:
public
int
Maximum
{
get
{
return
(
int
)GetValue(MaximumProperty); }
set
{ SetValue(MaximumProperty, value); }
}
public
static
readonly
DependencyProperty MaximumProperty =
DependencyProperty.Register(
"Maximum"
,
typeof
(
int
),
typeof
(SliderFilteringControl),
new
PropertyMetadata(0,
new
PropertyChangedCallback(
this
.OnMaximumPropertyChanged));
private
void
OnMaximumPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
this
.slider.Maximum = (
int
)e.NewValue;
}
<
local:SliderFilteringControl
Minimum
=
"0"
Maximum
=
"{Binding MyValue}"
/>
Regards,
Yavor Georgiev
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.
Thanks
Paolo
Simply modify the Prepare method of SliderFilteringControl like so:
public
void
Prepare(GridViewBoundColumnBase column)
{
if
(
this
.column != column)
{
this
.column = column;
string
dataMemberName =
this
.column.DataMemberBinding.Path.Path;
var distinctValues = column.DataControl.GetDistinctValues(column,
false
)
as
IEnumerable<
int
>;
this
.Minimum = distinctValues.Min();
this
.Maximum = distinctValues.Max();
SliderFilterViewModel vm =
new
SliderFilterViewModel(dataMemberName
,
this
.column.DataControl.FilterDescriptors
,
this
.Minimum
,
this
.Maximum);
Binding binding =
new
Binding(
"IsActive"
)
{
Source = vm,
Mode = BindingMode.OneWay
};
this
.ClearValue(SliderFilteringControl.IsActiveProperty);
this
.SetBinding(SliderFilteringControl.IsActiveProperty, binding);
this
.DataContext = vm;
}
}
Yavor Georgiev
the Telerik team
Thanks
Paolo
Check out this demo.
Sincerely yours,Yavor Georgiev
the Telerik team
Thanks
--tolga
Could you please share a code snippet? What exactly is your approach and how does it not work?
Regards,
Yavor Georgiev
the Telerik team
private Double _maximumNumberOfKeys;
public Double MaximumNumberOfKeys
{
get
{
return _maximumNumberOfKeys;
}
set
{
_maximumNumberOfKeys =
value;
OnPropertyChanged(
"MaximumNumberOfKeys");
}
}
private Double _selectedMaxNumberOfKeys;
public Double SelectedMaxNumberOfKeys
{
get
{
return _selectedMaxNumberOfKeys;
}
set
{
_selectedMaxNumberOfKeys =
value;
OnPropertyChanged(
"SelectedMaxNumberOfKeys");
}
}
public MainViewModel()
{
this.MaximumNumberOfKeys = 200;
this.SelectedMaxNumberOfKeys = 200;
OnPropertyChanged(
"MaximumNumberOfKeys");
OnPropertyChanged(
"SelectedMaxNumberOfKeys");
}
XAML
<
telerik:RadSlider Minimum="0"
Maximum="{Binding MaximumNumberOfKeys}"
SelectionStart="0"
SelectionEnd="{Binding SelectedMaxNumberOfKeys}"
MinimumRangeSpan="0"
MaximumRangeSpan="{Binding MaximumNumberOfKeys}"
IsSelectionRangeEnabled="True"
TickPlacement="TopLeft" />
So, both sliders are at 0. The "SelectionEnd" slider is not at "200" how I set it in the viewmodel. But the Maxium correctly displays "200" how I set it in the viewmodel. So, one works the other doesn't.
Thanks
--tolga
Have you tested this with the Beta version of the RadControls? Because we had this issue and we fixed it so it should work as expected now.
Can you please give it a try and let us know if you still experience the issue? Thank you in advance.
Greetings,
Tina Stancheva
the Telerik team
You can find it here : http://www.telerik.com/community/labs/betas.aspx
However, we just released the Q3 2010 official version of our controls and it is available for download from the "YourProducts" section in your account. Please test the issue with that version and let us know if you still experience it.
Best wishes,
Petar Mladenov
the Telerik team