• How To: Synchronize your UI selected items with your data context using MVVM and Blend behaviors for Silverlight and WPF

    Very often you need “two-way” binding between some UI component with multiple selection and a data context property for selected items – let’s say RadGridView and the following model:

    XAML

    <telerik:RadGridView  ItemsSource="{Binding  Data}"  SelectionMode="Extended"  SelectedItem="{Binding  SelectedItem,  Mode=TwoWay}">
    


    C#

        public class  MyDataContext  :  INotifyPropertyChanged
         {
             ...  ObservableCollection<MyObject> _SelectedItems;
             public  ObservableCollection<MyObject> SelectedItems
            {
                 get
                 {
                     if  (_SelectedItems ==  null)
                    {
                        _SelectedItems =  new  ObservableCollection<MyObject>();
                    }
                     return  _SelectedItems;
                }
            }
    
             MyObject  _SelectedItem;
             public  MyObject  SelectedItem
            {
                 get
                 {
                     return  _SelectedItem;
                ...
  • How To: Column chooser for RadGridView for Silverlight and WPF

    I’ve made small demo on how to create column chooser for any RadGridView in few very simple steps:

     

    1. Add new ChildWindow:
    ColumnChooser1

     

    2. Define following XAML for the child window:

    <Grid  x:Name="LayoutRoot"  Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition  Height="Auto" />
            <RowDefinition  />
        </Grid.RowDefinitions>
        <TextBlock  Text="Available columns:" />
        <ListBox  ItemsSource="{Binding  Columns}"  Grid.Row="1">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox  Content="{Binding  Header}"  IsChecked="{Binding  IsVisible,  Mode=TwoWay}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid...
  • How To: Custom percentage column with RadGridView, RadProgressBar and RadSlider for Silverlight and WPF

    Creating custom columns for RadGridView is super easy - all you need to do is to override CreateCellElement and/or CreateCellEditElement methods and return desired controls. To illustrate this I’ve made a column with RadProgressBar for view mode and RadSlider for edit mode:
     CustomPercentageColumn

    And here is the code:

    public class  GridViewPercentageColumn  :  GridViewDataColumn
    {
         public override  FrameworkElement  CreateCellElement(GridViewCell  cell,  object  dataItem)
        {
             var  bar = cell.Content  as  RadProgressBar;
    
             if  (bar ==  null)
            {
                bar =  new  RadProgressBar();
                bar.Height = 20;
                bar.SetBinding(RadProgressBar.ValueProperty,  this.DataMemberBinding);
                cell.Content = bar;
            }
    
             return  bar;
        }
    
         public override  FrameworkElement  CreateCellEditElement(...
  • Blazing fast performance with RadGridView for Silverlight 4, RadDataPager and WCF RIA Services

    In my previous post I’ve used almost 2 million records to the check the grid performance in WPF and I’ve decided to do the same for Silverlight 4 using WCF RIA Services. The grid again is bound completely codeless using DomainDataSource and RadDataPager:

      <Grid  x:Name="LayoutRoot">
    <
    Grid.RowDefinitions>
    <
    RowDefinition />
    <
    RowDefinition Height="Auto" />
    </
    Grid.RowDefinitions>
    <
    riaControls:DomainDataSource Name="orderDomainDataSource" QueryName="GetOrdersAndOrderDetails">
    <
    riaControls:DomainDataSource.DomainContext>
    <
    my:NorthwindDomainContext />
    </
    riaControls:DomainDataSource.DomainContext>
    </
    riaControls:DomainDataSource>
    <
    telerik:RadGridView Name="RadGridView1" IsReadOnly="True" ...
  • Blazing fast performance with RadGridView for WPF 4.0 and Entity Framework 4.0

    Just before our upcoming release of Q1 2010 SP1 (early next week), I’ve decided to check how RadGridView for WPF will handle complex Entity Framework 4.0 query with almost 2 million records:

    public class MyDataContext
    {
        IQueryable _Data;
        public IQueryable Data
        {
            get
            {
                if (_Data == null)
                {
                    var northwindEntities = new NorthwindEntities();
                    var queryable = from o in northwindEntities.Orders
                                   from od in northwindEntities.Order_Details
                                    select new
                                    {
                                        od.OrderID,
                                        od.ProductID,
                                        od.UnitPrice,
                                        od.Quantity,
                                        od.Discount,
                                        o.CustomerID,
                                        o.EmployeeID,
                                        o.OrderDate
                                    };
                    ...
  • How To: Filter as you type RadGridView inside RadComboBox for WPF and Silverlight

    I’ve made small example on how to place RadGridView inside editable RadComboBox and filter the grid items as you type in the combo:

    image

     

    The easiest way to place any UI element in RadComboBox is to create single RadComboBoxItem and define desired Template:

    <telerikInput:RadComboBox  Text="{Binding  Text,  Mode=TwoWay}"
                               IsEditable="True"  Height="25"  Width="200">
        <telerikInput:RadComboBox.Items>
            <telerikInput:RadComboBoxItem>
                <telerikInput:RadComboBoxItem.Template>
                    <ControlTemplate>
                        <telerikGrid:RadGridView  x:Name="RadGridView1"  ShowGroupPanel="False"  CanUserFreezeColumns="False" 
                                                  RowIndicatorVisibility="Collapsed"  IsReadOnly="True"
                                                  IsFilteringAllowed="False"  ItemsSource="{Binding  ...
  • Conditional styles and templates with RadGridView for Silverlight and WPF

    I’m happy to announce that with our upcoming Q1 2010 Service Pack 1 (middle of April) you will be able to apply conditionally styles and templates for RadGridView easily using DataTemplateSelectors and StyleSelectors for both Silverlight and WPF:

    image

    You can test the new functionally with our upcoming latest internal build this Friday and in the meantime here is an example:

    XAML

    <Grid  x:Name="LayoutRoot">
    <
    Grid.Resources>
    <
    local:MyStyleSelector x:Key="styleSelector" />
    <
    local:MyDataTemplateSelector x:Key="templateSelector" />
    </
    Grid.Resources>
    <
    telerik:RadGridView AutoGenerateColumns="False" ItemsSource="{Binding...
  • New Feature: RadGridView for Silverlight and WPF now can export totals to Excel, ExcelML, Word and CSV

    I’m happy to inform you that with our latest internal build you will be able to export the grid totals in all supported formats:

    Untitled

    Check the attached demo application & enjoy!

  • How To: Serialize your DataTable to Silverlight using WCF service

    Did you know that you can serialize any DataTable to Silverlight easily from your custom WCF service in very few lines of code?

    [OperationContract]
    public  IEnumerable<Dictionary<string,  object>> GetData()
    {
         var  table = YourDataTable;
    
         var  columns = table.Columns.Cast<DataColumn>();
    
         return  table.AsEnumerable().Select(r => columns.Select(c =>
                              new  { Column = c.ColumnName, Value = r[c] })
                         .ToDictionary(i => i.Column, i => i.Value !=  DBNull.Value ? i.Value :  null));
    }

     

    I’ve made small update for my lightweight DataTable for Silverlight and now you can create the table directly from IEnumerable<Dictionary<string, object>>:

    namespace  Telerik.Data
    {
         ...
  • How To: Print your DataGrid (or any UIElement) on multiple pages with Silverlight 4

    In Silverlight 4 you can use PrintDocument to print easily any UIElement:

       var doc = new PrintDocument();
       doc.DocumentName = YourDocumentName;

       doc.PrintPage += (s, e) =>
       {
            e.PageVisual = YouUIElement;
       };
       doc.Print();


    and I’ve made an extension method that can be used to print any UIElement on multiple pages:

    public static void Print(this UIElement source, string documentName)
    {
        var doc = new PrintDocument();
        doc.DocumentName = documentName;

        var offsetY = 0d;
        var totalHeight = 0d;

        var canvas = new Canvas();
        canvas.Children.Add(source); ...

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. »