or
<telerik:RadGridView x:Name="RadGridView1"
ItemsSource="{Binding ResultsViewModelList}" AutoGenerateColumns="False"
custom:GridViewDataColumnsBehavior.BindableColumns="{Binding ColumnCollection}"
...
// Toggle Column
GridViewToggleRowDetailsColumn gridRowToggle = new GridViewToggleRowDetailsColumn();
ColumnCollection.Add(gridRowToggle);
//data column
GridViewDataColumn column =
new
GridViewDataColumn();
string
columnName =
"column1"
;
column.Header = columnName;
column.UniqueName = columnName;
column.DataMemberBinding =
new
Binding(
"ResultDataDictionary["
+ columnName +
"]"
);
column.DataMemberBinding.StringFormat =
"0:N"
;
//also tried with N , {0:N}, ...
//also tried > column.DataFormatString = "0:N";
column.DataType =
typeof
(
double
);
ColumnCollection.Add(column);
public
static
readonly
DependencyProperty BindableColumnsProperty =
DependencyProperty.RegisterAttached(
"BindableColumns"
,
typeof
(ObservableCollection<GridViewColumn>),
typeof
(GridViewDataColumnsBehavior),
new
UIPropertyMetadata(
null
, BindableColumnsPropertyChanged));
private
static
void
BindableColumnsPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
{
RadGridView RadGridView = source
as
RadGridView;
ObservableCollection<GridViewColumn> columns = e.NewValue
as
ObservableCollection<GridViewColumn>;
RadGridView.Columns.Clear();
if
(columns ==
null
)
{
return
;
}
foreach
(GridViewColumn column
in
columns)
{
RadGridView.Columns.Add(column);
}
.....
01.
<
Window
x:Class
=
"WpfApplication1.MainWindow"
03.
xmlns:x
=
"http://schemas.microsoft.com/winfx/2006/xaml"
04.
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
05.
Title
=
"MainWindow"
>
06.
<
Window.Resources
>
07.
<
CollectionViewSource
x:Key
=
"MySource"
Source
=
"{Binding ItemsView}"
/>
08.
</
Window.Resources
>
09.
<
Grid
>
10.
<
StackPanel
>
11.
<
StackPanel
Orientation
=
"Horizontal"
Height
=
"200"
Margin
=
"10"
>
12.
<!-- binding directly to property ItemsView in DataContext/ViewModel ... WORKING -->
13.
<
telerik:RadGridView
AutoGenerateColumns
=
"True"
ItemsSource
=
"{Binding ItemsView}"
Width
=
"200"
/>
14.
<
telerik:RadDataForm
AutoGenerateFields
=
"True"
ItemsSource
=
"{Binding ItemsView}"
Width
=
"200"
/>
15.
</
StackPanel
>
16.
<
StackPanel
Orientation
=
"Horizontal"
Height
=
"200"
Margin
=
"10"
>
17.
<!-- binding to CollectionViewSource ... NOT working -->
18.
<
telerik:RadGridView
AutoGenerateColumns
=
"True"
ItemsSource
=
"{Binding Source={StaticResource MySource}}"
Width
=
"200"
/>
19.
<
telerik:RadDataForm
AutoGenerateFields
=
"True"
ItemsSource
=
"{Binding Source={StaticResource MySource}}"
Width
=
"200"
/>
20.
</
StackPanel
>
21.
</
StackPanel
>
22.
</
Grid
>
23.
</
Window
>
Partial Class Vehicle
{
public global::System.Int32 FaultCount
{
get
{
CCF20Entities ccf20Ent = new CCF20Entities();
return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "Vehcile" && f.VehicleID== this.VehicleID).Count();
}
}
}<
Window
x:Class
=
"Gauge.MainWindow"
xmlns:local
=
"clr-namespace:Gauge"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Width
=
"525"
Height
=
"500"
>
<
Window.Resources
>
<
Style
TargetType
=
"{x:Type telerik:Marker}"
>
<
Setter
Property
=
"telerik:ScaleObject.Location"
Value
=
"Outside"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type telerik:Marker}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Border
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
BorderBrush
=
"{TemplateBinding Background}"
BorderThickness
=
"2"
>
<
TextBlock
Width
=
"28.5"
Background
=
"{TemplateBinding Background}"
Foreground
=
"Black"
Opacity
=
"0.5"
Padding
=
"2,0"
Text="{Binding Value,
RelativeSource={RelativeSource TemplatedParent}}" />
</
Border
>
<
Rectangle
Width
=
"10"
Height
=
"2"
VerticalAlignment
=
"Center"
Fill
=
"{TemplateBinding Background}"
/>
</
StackPanel
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
Window.Resources
>
<
Grid
Background
=
"AliceBlue"
>
<
telerik:RadVerticalLinearGauge
Grid.Row
=
"1"
Grid.Column
=
"1"
Width
=
"100"
Height
=
"250"
OuterBackground
=
"Azure"
OuterBorderBrush
=
"Black"
telerik:StyleManager.Theme
=
"Windows8"
>
<
telerik:RadVerticalLinearGauge.Resources
>
<
Style
x:Key
=
"CustomTick"
TargetType
=
"Ellipse"
>
<
Setter
Property
=
"Fill"
Value
=
"White"
/>
<
Setter
Property
=
"Width"
Value
=
"5"
/>
<
Setter
Property
=
"Height"
Value
=
"5"
/>
<
Setter
Property
=
"telerik:ScaleObject.Location"
Value
=
"CenterInside"
/>
<
Setter
Property
=
"Canvas.ZIndex"
Value
=
"1001"
/>
</
Style
>
<
Style
x:Key
=
"CustomTickLine"
TargetType
=
"Rectangle"
>
<
Setter
Property
=
"telerik:ScaleObject.RelativeHeight"
Value
=
"0.07*"
/>
<
Setter
Property
=
"Width"
Value
=
"1"
/>
<
Setter
Property
=
"telerik:ScaleObject.Location"
Value
=
"CenterOutside"
/>
<
Setter
Property
=
"Canvas.ZIndex"
Value
=
"1001"
/>
</
Style
>
</
telerik:RadVerticalLinearGauge.Resources
>
<
telerik:VerticalLinearScale
IsInteractive
=
"True"
LabelUseRangeColor
=
"True"
Max
=
"4500"
Min
=
"0"
>
<
telerik:VerticalLinearScale.Ranges
>
<
telerik:GaugeRange
IndicatorBackground
=
"Red"
LabelForeground
=
"Red"
Max
=
"2000"
Min
=
"0"
TickBackground
=
"Red"
/>
<
telerik:GaugeRange
IndicatorBackground
=
"Green"
LabelForeground
=
"Green"
Max
=
"4500"
Min
=
"2000"
TickBackground
=
"Green"
/>
</
telerik:VerticalLinearScale.Ranges
>
<
telerik:VerticalLinearScale.Indicators
>
<
telerik:BarIndicator
x:Name
=
"barIndicator_main"
RangeColorMode
=
"Default"
UseRangeColor
=
"True"
Value
=
"4200"
/>
<
telerik:Marker
UseRangeColor
=
"True"
telerik:ScaleObject.Offset
=
"15"
telerik:ScaleObject.RelativeHeight
=
"20"
telerik:ScaleObject.RelativeWidth
=
"40"
Value="{Binding Value,
ElementName
=
barIndicator_main
}">
<
telerik:Marker.LayoutTransform
>
<
RotateTransform
Angle
=
"90"
CenterX
=
"0.5"
CenterY
=
"0.5"
/>
</
telerik:Marker.LayoutTransform
>
</
telerik:Marker
>
</
telerik:VerticalLinearScale.Indicators
>
<
telerik:VerticalLinearScale.CustomItems
>
<
Ellipse
Stroke
=
"Red"
Style
=
"{StaticResource CustomTick}"
telerik:ScaleObject.Value
=
"0"
>
<!--<
Ellipse.LayoutTransform
>
<
RotateTransform
Angle
=
"90"
CenterX
=
"0.5"
CenterY
=
"0.5"
/>
</
Ellipse.LayoutTransform
>-->
</
Ellipse
>
<
Rectangle
Fill
=
"Red"
Style
=
"{StaticResource CustomTickLine}"
telerik:ScaleObject.Value
=
"0"
>
<!--<
Rectangle.LayoutTransform
>
<
RotateTransform
Angle
=
"90"
CenterX
=
"0.5"
CenterY
=
"0.5"
/>
</
Rectangle.LayoutTransform
>-->
</
Rectangle
>
<!--
<
TextBlock
FontWeight
=
"Bold"
Foreground
=
"Red"
Text
=
"2000"
telerik:ScaleObject.Location
=
"Outside"
telerik:ScaleObject.Value
=
"2000"
/>
-->
</
telerik:VerticalLinearScale.CustomItems
>
</
telerik:VerticalLinearScale
>
</
telerik:RadVerticalLinearGauge
>
</
Grid
>
</
Window
>
Thanks.
public override FrameworkElement CreateFieldFilterEditor()
{
TextBox searchTextBox = new TextBox();
Binding searchTextBinding = new Binding("Value");
searchTextBinding.Mode = BindingMode.TwoWay;
searchTextBinding.FallbackValue = null;
searchTextBox.SetBinding(TextBox.TextProperty, searchTextBinding);
return searchTextBox;
}