or
<
telerik:RadGridView
x:Name
=
"HistoryData"
GroupRenderMode
=
"Flat"
GridLinesVisibility
=
"Vertical"
ColumnWidth
=
"50"
CanUserFreezeColumns
=
"False"
AutoGenerateColumns
=
"False"
AutoExpandGroups
=
"True"
IsFilteringAllowed
=
"True"
ShowGroupPanel
=
"False"
RowIndicatorVisibility
=
"Collapsed"
d:DataContext
=
"{d:DesignData Source=../SampleData/SampleData.xaml}"
>
<
t:RadAutoCompleteBox
x:Name
=
"AutoCompleteBox"
Grid.Row
=
"2"
Grid.ColumnSpan
=
"3"
ItemsSource
=
"{Binding Suggests}"
SearchText
=
"{Binding TextSearch, Mode=TwoWay}"
SelectedItem
=
"{Binding SelectedSuggest, Mode=TwoWay}"
TextSearchPath
=
"SearchPath"
DisplayMemberPath
=
"Name"
>
<
t:RadAutoCompleteBox.DropDownItemTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
<
TextBlock
Text
=
" - "
/>
<
TextBlock
Text
=
"{Binding Code}"
/>
</
StackPanel
>
</
DataTemplate
>
</
t:RadAutoCompleteBox.DropDownItemTemplate
>
</
t:RadAutoCompleteBox
>
public
class
GridViewHeaderMenu
{
private
readonly
RadGridView grid =
null
;
public
GridViewHeaderMenu(RadGridView grid)
{
this
.grid = grid;
}
public
static
readonly
DependencyProperty IsEnabledProperty
= DependencyProperty.RegisterAttached(
"IsEnabled"
,
typeof
(
bool
),
typeof
(GridViewHeaderMenu),
new
PropertyMetadata(
new
PropertyChangedCallback(OnIsEnabledPropertyChanged)));
public
static
void
SetIsEnabled(DependencyObject dependencyObject,
bool
enabled)
{
dependencyObject.SetValue(IsEnabledProperty, enabled);
}
public
static
bool
GetIsEnabled(DependencyObject dependencyObject)
{
return
(
bool
)dependencyObject.GetValue(IsEnabledProperty);
}
private
static
void
OnIsEnabledPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
RadGridView grid = dependencyObject
as
RadGridView;
if
(grid !=
null
)
{
if
((
bool
)e.NewValue)
{
// Create new GridViewHeaderMenu and attach RowLoaded event.
GridViewHeaderMenu menu =
new
GridViewHeaderMenu(grid);
menu.Attach();
}
}
}
private
void
Attach()
{
if
(grid !=
null
)
{
// create menu
RadContextMenu contextMenu =
new
RadContextMenu();
// set menu Theme
StyleManager.SetTheme(contextMenu, StyleManager.GetTheme(grid));
contextMenu.Opened += OnMenuOpened;
contextMenu.ItemClick += OnMenuItemClick;
RadContextMenu.SetContextMenu(grid, contextMenu);
}
}
void
OnMenuOpened(
object
sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
GridViewHeaderCell cell = menu.GetClickedElement<GridViewHeaderCell>();
if
(cell !=
null
)
{
menu.Items.Clear();
RadMenuItem item =
new
RadMenuItem();
item.Header = String.Format(@Klassen.Language.GetTextbyCode(
"SortAufsteigend"
) + cell.Column.Header);
menu.Items.Add(item);
item =
new
RadMenuItem();
item.Header = String.Format(@Klassen.Language.GetTextbyCode(
"SortAbsteigend"
) + cell.Column.Header);
menu.Items.Add(item);
item =
new
RadMenuItem();
item.Header = String.Format(@Klassen.Language.GetTextbyCode(
"SortClear"
) + cell.Column.Header);
menu.Items.Add(item);
item =
new
RadMenuItem();
item.Header = Klassen.Language.GetTextbyCode(
"ChooseColumns"
);
menu.Items.Add(item);
// create menu items
foreach
(GridViewColumn column
in
grid.Columns)
{
RadMenuItem subMenu =
new
RadMenuItem();
subMenu.Header = column.Header;
subMenu.IsCheckable =
true
;
subMenu.IsChecked =
true
;
Binding isCheckedBinding =
new
Binding(
"IsVisible"
);
isCheckedBinding.Mode = BindingMode.TwoWay;
isCheckedBinding.Source = column;
// bind IsChecked menu item property to IsVisible column property
subMenu.SetBinding(RadMenuItem.IsCheckedProperty, isCheckedBinding);
item.Items.Add(subMenu);
}
}
else
{
menu.IsOpen =
false
;
}
}
void
OnMenuItemClick(
object
sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
GridViewHeaderCell cell = menu.GetClickedElement<GridViewHeaderCell>();
RadMenuItem clickedItem = ((RadRoutedEventArgs)e).OriginalSource
as
RadMenuItem;
GridViewColumn column = cell.Column;
if
(clickedItem.Parent
is
RadMenuItem)
return
;
string
header = Convert.ToString(clickedItem.Header);
using
(grid.DeferRefresh())
{
ColumnSortDescriptor sd = (from d
in
grid.SortDescriptors.OfType<ColumnSortDescriptor>()
where
object
.Equals(d.Column, column)
select d).FirstOrDefault();
if
(header.Contains(
"Sort Ascending"
))
{
if
(sd !=
null
)
{
grid.SortDescriptors.Remove(sd);
}
ColumnSortDescriptor newDescriptor =
new
ColumnSortDescriptor();
newDescriptor.Column = column;
newDescriptor.SortDirection = ListSortDirection.Ascending;
grid.SortDescriptors.Add(newDescriptor);
}
else
if
(header.Contains(
"Sort Descending"
))
{
if
(sd !=
null
)
{
grid.SortDescriptors.Remove(sd);
}
ColumnSortDescriptor newDescriptor =
new
ColumnSortDescriptor();
newDescriptor.Column = column;
newDescriptor.SortDirection = ListSortDirection.Descending;
grid.SortDescriptors.Add(newDescriptor);
}
else
if
(header.Contains(
"Clear Sorting"
))
{
if
(sd !=
null
)
{
grid.SortDescriptors.Remove(sd);
}
}
}
}
}
<
chart:RadCartesianChart
x:Name
=
"RadChart1"
Palette
=
"Windows8"
Margin
=
"20,0,8,0"
example:FinancialIndicatorSwitch.MainIndicator
=
"{Binding MainIndicator, Mode=TwoWay}"
example:FinancialSeriesTypeSwitch.SeriesType
=
"{Binding SeriesType}"
and
<chart:RadCartesianChart
x:Name
=
"RadChart2"
Palette
=
"Windows8"
Grid.Row
=
"1"
Margin
=
"20,10,8,0"
example:FinancialIndicatorSwitch.SecondaryIndicator
=
"{Binding SecondaryIndicator, Mode=TwoWay}"
>