or
<Window x:Class="RadGridViewScrollingSample.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:local="clr-namespace:RadGridViewScrollingSample" x:Name="_this" Title="MainWindow" Height="350"> <Window.Resources> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> </Window.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"> <TextBlock Text='Scroll down in the grid view below then move the mouse over "Place Mouse Here".'/> <TextBlock Text="You will see the grid view automatically scroll to the top."/> <TextBlock Text='Clicking in "Place Mouse Here" will scroll the last row of the grid view in to view, but'/> <TextBlock Text='the grid view will again scroll to the top when the mouse is moved outside "Place Mouse Here".'/> </StackPanel> <telerik:RadGridView x:Name="gridView" Grid.Row="1" Grid.Column="0" ScrollViewer.VerticalScrollBarVisibility="Visible" ItemsSource="{Binding Path=Things}"/> <TextBlock Grid.Row="1" Grid.Column="1" x:Name="placeholder" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Text="Place Mouse Here" FontSize="40" MouseUp="OnMouseUp"/> <DockPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"> <TextBlock Text="This is placeholder text. "/> <TextBlock Text='This text appears when the mouse is over "Place Mouse Here".' Visibility="{Binding ElementName=placeholder, Path=IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}}"/> </DockPanel> </Grid></Window>using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.Collections.ObjectModel;using System.ComponentModel;namespace RadGridViewScrollingSample{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private ObservableCollection<Thing> things = new ObservableCollection<Thing>(); private string[] colors = new string[] { "red", "green", "blue", "orange", "purple" }; private string[] sizes = new string[] { "small", "medium", "large" }; public MainWindow() { InitializeComponent(); DataContext = this; int i = 0; for (char c = 'A'; c <= 'Z'; c++, i++) { things.Add(new Thing(c.ToString(), colors[i % colors.Length], sizes[i % sizes.Length])); } } public ObservableCollection<Thing> Things { get { return things; } } private void OnMouseUp(object sender, MouseButtonEventArgs e) { gridView.ScrollIntoView(things.FirstOrDefault(t => t.Name == "Z")); } } public class Thing { private string name; private string color; private string size; public Thing(string name, string color, string size) { this.name = name; this.color = color; this.size = size; } public string Name { get { return name; } } public string Color { get { return color; } } public string Size { get { return size; } } }}
private void radDocking_ElementLoading( object sender, Telerik.Windows.Controls.LayoutSerializationLoadingEventArgs e ){ var pane = e.AffectedElement as RadPane; if ( pane != null ) { pane.Content = this.GetPaneContent( e.AffectedElementSerializationTag ); }}RadPaneGroup radPaneGroup = new RadPaneGroup { VerticalAlignment = VerticalAlignment.Top, VerticalContentAlignment = VerticalAlignment.Top }; this.view.splitContainer.Items.Add(radPaneGroup); RadPane radPane = new RadPane { Content = createdChartView, CanUserClose = true, Title = createdChartView.DisplayName, }; RadDocking.SetSerializationTag(radPane, chartConfiguration.Id.ToString()); RadDocking.SetSerializationTag(radPaneGroup, chartConfiguration.Id.ToString()); radPaneGroup.Items.Add(radPane); this.hostedCharts.Add(chartConfiguration.Id, createdChartView);private void RadDockingOnElementLoaded(object sender, LayoutSerializationEventArgs e) { RadPane newPane = e.AffectedElement as RadPane; if (newPane != null) { ChartView chartView = ((ChartHostViewModel)this.DataContext).GetPaneContent(e.AffectedElementSerializationTag); RadPane oldParentPane = (RadPane)chartView.Parent; if (oldParentPane != null) { RadPaneGroup oldParentGroup = (RadPaneGroup)oldParentPane.Parent; if (oldParentGroup != null) { RadSplitContainer oldSplitContainer = (RadSplitContainer)oldParentGroup.Parent; if (oldSplitContainer != null) { oldSplitContainer.Items.Remove(oldParentGroup); } oldParentGroup.Items.Remove(oldParentPane); } oldParentPane.Content = null; } newPane.Content = chartView; return; } RadPaneGroup newPaneGroup = e.AffectedElement as RadPaneGroup; if (newPaneGroup != null) { newPaneGroup.VerticalAlignment = VerticalAlignment.Top; newPaneGroup.VerticalContentAlignment = VerticalAlignment.Top; } }
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CheckBox));factory.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));factory.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));factory.SetValue(CheckBox.ToolTipProperty, "(De)Select All");DataTemplate template = new DataTemplate();template.DataType = typeof(bool);template.VisualTree = factory;
GridViewCheckBoxColumn column = new GridViewCheckBoxColumn();column.DataMemberBinding = new Binding(prefix + property.Name);column.Header = template // <-- this does not work
var customerids = from c in customersQueryView select c.customerid;var customerids = from c in customersQueryView.AsQueryable() select c.customerid;class CustomGridViewToggleRowDetailsColumn : GridViewBoundColumnBase { public static RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent( "Click", RoutingStrategy.Bubble, typeof( ToggleRowDetailsColumnRoutedEventHandler ), typeof( CustomGridViewToggleRowDetailsColumn ) ); public GridViewCell Cell { get; set; } public event RoutedEventHandler Click { add { AddHandler( ClickEvent, value ); } remove { RemoveHandler( ClickEvent, value ); } } public override object Header { get { return null; } set { base.Header = value; } } public GridViewToggleButton ToggleButton { get; set; } private Binding toggleButtonVisibility; public Binding ToggleButtonVisibility { get { return toggleButtonVisibility; } set { toggleButtonVisibility = value; } } public CustomGridViewToggleRowDetailsColumn() { this.EditTriggers = GridViewEditTriggers.None; } public override bool CanFilter() { return false; } public override bool CanGroup() { return false; } public override bool CanSort() { return false; } public override FrameworkElement CreateCellElement( GridViewCell cell, object dataItem ) { Cell = cell; ToggleButton = new GridViewToggleButton { Margin = new System.Windows.Thickness( 3 ) }; ToggleButton.Click += new RoutedEventHandler( ToggleButton_Click ); if ( this.DataMemberBinding != null ) { ToggleButton.SetBinding( GridViewToggleButton.IsCheckedProperty, this.DataMemberBinding ); } if ( ToggleButtonVisibility != null ) { ToggleButton.SetBinding( GridViewToggleButton.VisibilityProperty, ToggleButtonVisibility ); } GridViewRow row = cell.ParentRow as GridViewRow; row.SetBinding( GridViewRow.DetailsVisibilityProperty, new Binding( "IsChecked" ) { Source = ToggleButton, Converter = new BooleanToVisibilityConverter(), Mode = BindingMode.TwoWay } ); return ToggleButton; } void ToggleButton_Click( object sender, RoutedEventArgs e ) { // Raise our Click event RoutedEventArgs newEventArgs = new ToggleRowDetailsColumnRoutedEventArgs( ClickEvent, Cell ); RaiseEvent( newEventArgs ); } } public class ToggleRowDetailsColumnRoutedEventArgs : RoutedEventArgs { public GridViewCell Cell { get; set; } public GridViewRow Row { get { return Cell.ParentRow as GridViewRow; } } public ToggleRowDetailsColumnRoutedEventArgs( RoutedEvent routedEvent, GridViewCell cell ) : base( routedEvent ) { Cell = cell; } } public delegate void ToggleRowDetailsColumnRoutedEventHandler( object sender, ToggleRowDetailsColumnRoutedEventArgs e );private void ExpandAlarms_Click( object sender, ToggleRowDetailsColumnRoutedEventArgs e ) { ReadViewModel read = e.Row.Item as ReadViewModel; if ( read.Alarms == null ) { read.Alarms = DataInterface.GetAlarmsForRead( read.ID ); } e.Handled = true; }