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 Telerik.Windows.Controls;
using Telerik.Windows.Data;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<Person> allPersons = new List<Person>();
createGridColumns();
allPersons.Add(new Person() { LastName = "Doe", FirstName = "John", Number1 = 1, Number2 = 2, Number3 = 3 });
allPersons.Add(new Person() { LastName = "Fraser", FirstName = "Joe", Number1 = 4, Number2 = 2, Number3 = 6 });
allPersons.Add(new Person() { LastName = "Alban", FirstName = "Ricardo", Number1 = 7, Number2 = 8, Number3 = 9 });
gridViewTest.ItemsSource = allPersons;
}
private void createGridColumns()
{
GridViewDataColumn col1 = new GridViewDataColumn();
GridViewDataColumn col2 = new GridViewDataColumn();
GridViewDataColumn col3 = new GridViewDataColumn();
GridViewDataColumn col4 = new GridViewDataColumn();
GridViewDataColumn col5 = new GridViewDataColumn();
col1.Header = "LastName";
col1.UniqueName = "col1";
col1.DataMemberBinding = new Binding("LastName");
col1.AggregateFunctions.Add(new CountFunction() { Caption = "Count: " });
col2.Header = "FirstName";
col2.UniqueName = "col2";
col2.DataMemberBinding = new Binding("FirstName");
col2.AggregateFunctions.Add(new FirstFunction() { Caption = "First: " });
col2.AggregateFunctions.Add(new LastFunction() { Caption = "Last: " });
col2.AggregateFunctions.Add(new MinFunction() { Caption = "Min: " });
col2.AggregateFunctions.Add(new MaxFunction() { Caption = "Max: " });
col3.Header = "Number1";
col3.UniqueName = "col3";
col3.DataFormatString = "C2";
col3.DataMemberBinding = new Binding("Number1");
col3.AggregateFunctions.Add(new MinFunction() { Caption = "Min: " });
col3.AggregateFunctions.Add(new MaxFunction() { Caption = "Max: " });
col4.Header = "Number2";
col4.UniqueName = "col4";
col4.DataFormatString = "C2";
col4.DataMemberBinding = new Binding("Number2");
col4.AggregateFunctions.Add(new AverageFunction() { Caption = "Avg: ", SourceFieldType=typeof(decimal) }); // *** Put this line in comment to have a working app ***
col5.Header = "Number3";
col5.UniqueName = "col5";
col5.DataFormatString = "C2";
col5.DataMemberBinding = new Binding("Number3");
col5.AggregateFunctions.Add(new SumFunction() { Caption = "Sum: ", SourceFieldType = typeof(decimal) }); // *** Put this line in comment to have a working app ***
gridViewTest.Columns.Add(col1);
gridViewTest.Columns.Add(col2);
gridViewTest.Columns.Add(col3);
gridViewTest.Columns.Add(col4);
gridViewTest.Columns.Add(col5);
}
}
public class Person
{
public object LastName { get; set; }
public object FirstName { get; set; }
public object Number1 { get; set; }
public object Number2 { get; set; }
public object Number3 { get; set; }
}
}
<Window.Resources> <CollectionViewSource x:Key="orderViewSource" /></Window.Resources><Grid> <ItemsControl x:Name="rptOrders" ItemsSource="{Binding Source={StaticResource orderViewSource}}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="160px" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Label Content="{Binding Path=Name}" Grid.Column="0" VerticalAlignment="Center"></Label> <telerik:RadComboBox x:Name="rcbOrder" Grid.Column="1" SelectedItem="{Binding Path=Order}"> <telerik:RadComboBoxItem Content="Extra Hot" /> <telerik:RadComboBoxItem Content="Hot" /> <telerik:RadComboBoxItem Content="Mild" /> </telerik:RadComboBox> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl></Grid>((CollectionViewSource)(FindResource("orderViewSource"))).Source = Data.StaffOrders;public class Data{ public static ObservableCollection<StaffMember> StaffOrders { get { return //loaddata; } } public class StaffMember { public Int32 StaffID { get; set; } public String Name { get; set; } public String Email { get; set; } public String Order { get; set; } }}<Window x:Class="RadControlsWpfApp1.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style TargetType="ListBox" x:Key="TelerikListBoxStyle" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Office_BlueTheme, ElementType=ListBox}}"/> </Window.Resources> <StackPanel Orientation="Vertical"> <ListBox Style="{StaticResource TelerikListBoxStyle}" x:Name="telerikStyledListBox" HorizontalContentAlignment="Stretch"> <ListBox.ItemTemplate> <DataTemplate> <Label Content="telerik style" BorderThickness="1" BorderBrush="Black"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <ListBox x:Name="listBox" HorizontalContentAlignment="Stretch"> <ListBox.ItemTemplate> <DataTemplate> <Label Content="standard style" BorderThickness="1" BorderBrush="Black"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel></Window>