VIBlend

How to bind the VIBlend DataGrid for Silverlight and WPF to Indexed properties?

by viblend 3. September 2010 19:48

In order to bind the VIBlend DataGrid to indexed properties, you need to do the following:

1. Create DataTemplates that are bound to indexed properties.

        <DataTemplate x:Key="LastNameCellTemplate">
            <Grid>
                <TextBlock Text="{Binding [LastName], Mode=OneWay}"/>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="FirstNameCellTemplate">
            <Grid>
                <TextBlock Text="{Binding [FirstName], Mode=OneWay}"/>
            </Grid>
        </DataTemplate>

2. Create a new DataGrid instance. Set the CellDataTemplate property of the DataGrid’s BoundFields to point to the DataTemplates.

        <viblend:DataGrid x:Name="dataGrid" Width="400" Height="280" AutoGenerateColumns="True">
            <viblend:DataGrid.BoundFields>
                <viblend:BoundField Text="FirstName" Width="150" CellDataTemplate="{StaticResource FirstNameCellTemplate}"/>
                <viblend:BoundField Text="LastName" Width="150" CellDataTemplate="{StaticResource LastNameCellTemplate}"/>
            </viblend:DataGrid.BoundFields>
        </viblend:DataGrid>

3.  Create a new class that will represent a single record of the DataGrid.

CSharp

public class Person : INotifyPropertyChanged
{   
    public Person()
    {
    }

    private Dictionary<string, object> data = new Dictionary<string, object>();

    public object this[string key]
    {
        get
        {
            if (!data.ContainsKey(key))
            {
                data[key] = null;
            }
            return data[key];
        }
        set
        {
            data[key] = value;
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(""));
            }
        }
    }

    public IEnumerable<string> Keys
    {
        get
        {
            return data.Keys;
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}

VB .NET

Public Class Person
    Implements INotifyPropertyChanged
    Public Sub New()
    End Sub

    Private data As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()

    Default Public Property Item(ByVal key As String) As Object
        Get
            If (Not data.ContainsKey(key)) Then
                data(key) = Nothing
            End If
            Return data(key)
        End Get
        Set(ByVal value As Object)
            data(key) = value
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(""))
        End Set
    End Property

    Public ReadOnly Property Keys() As IEnumerable(Of String)
        Get
            Return data.Keys
        End Get
    End Property

    Public Event PropertyChanged As PropertyChangedEventHandler
End Class

4.  Create a new generic List of Person objects and set the ItemsSource property of the DataGrid, in order to bind it to the list.

CSharp

       List<Person> listOfPersons = new List<Person>();
       for (int i = 0; i < 10; i++)
       {
           Person person = new Person();
           person["FirstName"] = "FirstName" + i;
           person["LastName"] = "LastName" + i;
           listOfPersons.Add(person);
       }
       this.dataGrid.ItemsSource = listOfPersons;

VB .NET

      Dim listOfPersons As List(Of Person) = New List(Of Person)()
      For i As Integer = 0 To 9
         Dim person As New Person()
         person("FirstName") = "FirstName" & i
         person("LastName") = "LastName" & i
         listOfPersons.Add(person)
      Next i
      Me.dataGrid.ItemsSource = listOfPersons

VIBlend WinForms Controls ver. 4.6 – Released

by viblend 22. April 2010 09:17

We are happy to announce the release of the latest version of VIBlend Controls for WinForms.

VIBlend Windows Forms Controls 4.6.0 - Release Notes

1. Added support for Visual Studio 2010
2. Moved all design time classes of our controls to separate assembly
3. DataGridView changes

In this version we extended the HierarhcyItem mouse click events. Previously, the grid was raising only the ItemClick and ItemDoubleClick events.

These two events are replaced by the following set of events:

 - HierarchyItemMouseUp
 - HierarchyItemMouseDown
 - HierarchyItemMouseClick
 - HierarchyItemMouseDoubleClick

We also added several improvements in the in-place cell editors' infrastructure. Specifically we added the following activation and deactivation events:

 - Click on selected cell (MOUSE_CLICK_SELECTED_CELL)
 - Enter key activation (KEY_PRESS_ENTER
 - Esc key deactivation (KEY_PRESS_ESC)

The default activation and deactivation flags for the built-in cell editors where modified to use the new activation events.

Please, note that these are breaking changes. If you are using an earlier version of VIBlend Controls for Windows Forms you will have to make minor changes to your code.

New in version 4.6 are the HierarchyItems and Cells selection changed events:
 - DataGridView.HierarchyItemSelectionChanged
 - DataGridView.CellSelectionChanged

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

DataGrid | olap grid | winforms grid | WinForms

Pivot Grid - Traditional vs Compact style layout

by viblend 18. April 2010 05:36

VIBlend DataGridView for WinForms offers multiple unique features that cannot be found in other Windows Forms data grid controls. These include multi-level hierarchies on rows and columns, rows grouping, pivot tables, and built-in OLAP capabilities. One of the main drawbacks of the traditional OLAP style rows layout is that it takes a lot of screen space. 

 

This could be improved by using the compact style layout. In this mode the rows of the pivot table are rendered in a tree-like structure.

 


Switching from default to compact style rendering is very easy. It requires setting the value of RowsHierarchy.CompactStyleRendering property to true:

C#
grid.RowsHierarchy.CompactStyleRenderingEnabled = true;
grid.RowsHierarchy.AutoResize();
grid.Invalidate();

VB .Net
grid.RowsHierarchy.CompactStyleRenderingEnabled = True
grid.RowsHierarchy.AutoResize()
grid.Invalidate()
 

You can switch between traditional and compact style rendering at runtime. The feature is also availalbe in VIBlend DataGrid for Silverlight.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , ,

DataGrid | olap grid | pivot, olap

Visual Studio 2010 and .Net Framework 4.0

by viblend 12. April 2010 03:22

VIBlend will fully support the .NET4 Client Profile in the next version of VIBlend Controls for WinForms which is expected in the middle of May. We will create a new VIBlend.WinForms.Controls.Design assembly and will move all the design time classes of our controls into it. The change is needed because the client profile does not include the standard design time classes and we need to remove the reference to the System.Design namespace in our present assemblies.

The upcoming release of the VIBlend Controls for Silverlight, which is due in May, will incorporate a full support for Visual Studio 2010. We will also have a new build for Silverlight 4 and our product will benefit from the new features in the latest platform’s edition. In addition, the new release will be shipped with three new themes for all of our controls and performance optimizations in the VIBlend OLAP Grid for Silverlight.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

DataGrid | Industry news | olap grid | pivot grid | Silverlight Controls | winforms grid

Using VIBlend DataGridView for WinForms in a WPF Application

by viblend 3. April 2010 21:56

In this blog post we will show you how to use the VIBlend DataGridView for WinForms in a WPF application.

The following code example creates a WinForms DataGrid control with Office2010Black theme in a WPF application. This example uses a WindowsFormsHost element to place the DataGrid control within the main window’s root  element. The WindowsFormsHost element could be found in the WindowsFormsIntegration.dll.

[xaml]

  <Window x:Class="HostWinFormsControlInWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viblend="clr-namespace:VIBlend.WinForms.DataGridView;assembly=VIBlendGrid"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <WindowsFormsHost>
            <viblend:vDataGridView x:Name="VIBlendDataGrid" VIBlendTheme="OFFICE2010BLACK"/>               
        </WindowsFormsHost>
    </Grid>
</Window>

In order to bind the data grid, you need to do the following:  Click on the Data menu item in your Visual Studio, then select the “Add new DataSource” item.  Browse to the Nwind.mdb which ships with the WinForms controls installation, choose the Employees table and click finish. In the code behind, after the InitializeComponent call or in the Load event handler , bind the data grid to the Employees table.

            NwindDataSet dataSet = new NwindDataSet();
            EmployeesTableAdapter adapter = new EmployeesTableAdapter();
            adapter.Fill(dataSet.Employees);
            this.VIBlendDataGrid.DataSource = dataSet.Employees.DefaultView;
            this.VIBlendDataGrid.DataBind();

Here is the result:

VIBlend Silverlight Controls - ver. 2.0 Released

by viblend 3. March 2010 05:26

We are proud to announce the second major release of VIBlend Controls for Silverlight.

With the new release, VIBlend has officially included in the suite four new controls – OutlookPane, NavigationPane, DateTimePicker and ScrollablePanel. Not only we introduced new controls, but we also improved the quality and functionality of the existing ones and added over 10 new examples to show how our controls work.

The Menu and Context Menu controls from the toolset are now provided free of charge to all registered users.

See our Silverlight Controls Live Demo and Download a free trial today.

Creating a Pivot Table in Silverlight using XAML

by viblend 13. January 2010 17:21

New in version 1.4 of VIBlend Silverlight Controls is the ability to create a Pivot Table entirely in XAML.

As usual you have to specify which columns (data fields) from the data source will represent the pivot table's rows, columns and values fields.

Below is the full XAML required to declare a pivot table:

<UserControl x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="800"
    xmlns:viblend="clr-namespace:VIBlend.Silverlight.Controls;assembly=DataGrid">

    <Grid x:Name="LayoutRoot" Background="White">
            <viblend:DataGrid AutoGenerateColumns="True" PivotValuesOnRows="False" Name="dataGrid1"  Height="200" Width="500">
                <viblend:DataGrid.BoundPivotRows>
                    <viblend:BoundField DataField="Country" Text="Country"/>
                    <viblend:BoundField DataField="Region" Text="Region"/>
                    <viblend:BoundField DataField="City" Text="City"/>
                </viblend:DataGrid.BoundPivotRows>
                <viblend:DataGrid.BoundPivotColumns>
                   <viblend:BoundField DataField="ShipperCompany" Text="Shipper Company"/>
                </viblend:DataGrid.BoundPivotColumns>
                <viblend:DataGrid.BoundPivotValues>
                    <viblend:BoundValueField DataField="ExtendedPrice" Text="Count of Sales" Function="Count"/>
                    <viblend:BoundValueField DataField="ExtendedPrice" Text="Amount of Sales" Function="Sum"/>
                    <viblend:BoundValueField DataField="ExtendedPrice" Text="Avg Sale Amount" Function="Average"/>
                </viblend:DataGrid.BoundPivotValues>
            </viblend:DataGrid>
    </Grid>
</UserControl>

After that simply bind to the data source by setting the ItemsSource property of the data grid control:

dataGrid1.ItemsSource = myData;

The result is a great looking pivot table with interactive drill down support.

VIBlend DataGrid for Silverlight uses a built-in OLAP engine to construct the pivot table. You can bind the DataGrid to any data source and easily build in-house Business Intelligence and reporting tools within minutes.

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

olap | olap grid | pivot grid | Silverlight

VIBlend Silverlight Controls – Announcing new version 1.3

by viblend 27. December 2009 19:37

We are proud to announce the release of the latest version of VIBlend Silverlight Controls.

The new edition includes many improvements in VIBlend’s OLAP Grid for Silverlight:

  • Significantly better performance
  • Lower memory use
  • Data binding improvements and LINQ support
  • Layout enhancements with variable height columns
  • Pivot table sorting by label
  • Better design time support in Visual Studio 2010 Beta

The release of version 1.3 brings a new Silverlight TreeView control loaded with advanced features, stylish animations and offering easy to use and flexible programming model.

See our Silverlight Controls Live Demo and Download a free trial today.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

olap | pivot | Silverlight | pivot grid | olap grid

Cross-platform OLAP with VIBlend Silverlight Pivot Grid

by viblend 27. November 2009 07:50

In a typical data grid, the data is flat and consists of many rows and columns. The data may contain cells with same values and working with the raw data may not be the best way to spot patterns and analyze trends. Many data grid controls provide rows grouping functionality which allows you to group multiple rows by columns where the corresponding grid cells have the same value.
Pivot tables go one step further and enable powerful data analysis. A Pivot table consists of rows, columns and data (value/fact) fields.
VIBlend DataGrid for Silverlight features a built-in data aggregation engine which is capable of turning any tabular data source into a wide variety of cross tab views. This is similar to the Pivot tables functionality in Excel. Creating a Pivot table with VIBlend DataGrid for Silverlight is very easy. In fact, the data binding to the data source is no different than data binding any other control to a collection. Assume that you have a table with five columns: Country, Region, City, ShipperCompany and ExtendedPrice. You need to choose the columns from the data source and add them to the BoundFields collection:

  CSharp:


pivotGrid1.BoundFields.Add(new BoundField("Country", "Country"));
pivotGrid1.BoundFields.Add(new BoundField("Region", "Region"));
pivotGrid1.BoundFields.Add(new BoundField("City", "City"));
pivotGrid1.BoundFields.Add(new BoundField(
"Shipper Company ", "ShipperCompany"));
pivotGrid1.BoundFields.Add(new BoundField(
"ExtendedPrice", "ExtendedPrice"));


Using this code, once you data bind to the data source, the grid will display all table rows and the five columns: Country, Region, City, Carrier, Extended Price.
However, let’s look at a scenario where we want to show count of sales, amount of sales, and average sale amount grouped by Country, by Region and by City, and do that for each Shipper Company.
This requires only a few extra lines of code:

1. Assign the Country, Region and City fields to form the Rows hierarchy:

CSharp:

pivotGrid1.BoundPivotRows.Add(new BoundField("Country", "Country"));
pivotGrid1.BoundPivotRows.Add(new BoundField("Region", "Region"));
pivotGrid1.BoundPivotRows.Add(new BoundField("City", "City"));


2. Assign the ShipperCompany field to form the Columns hierarchy:

CSharp:

pivotGrid1.BoundPivotColumns.Add(new BoundField(
"Shipper Company", "ShipperCompany"));


3. Assign the ExtendedPrice field to form the facts/values for count of sales, sales amount, and average sale amount:

CSharp:

pivotGrid1.BoundPivotValues.Add(new BoundValueField("Count of Sales", "ExtendedPrice", PivotFieldFunction.Count));
pivotGrid1.BoundPivotValues.Add(new BoundValueField("Amount of Sales", "ExtendedPrice", PivotFieldFunction.Sum));
pivotGrid1.BoundPivotValues.Add(new BoundValueField("Avg Sale Amount", "ExtendedPrice", PivotFieldFunction.Average));


4. Specify if the value/fact columns appear attached to the rows or to the columns:

CSharp:

pivotGrid1.PivotValuesOnRows = false;


During the data binding process, the OLAP engine in VIBlend DataGrid for Silverlight will parse the table content, build the rows and columns hierarchies, and compute the pivot table cell values. The result will be the following pivot table view:


Silverlight Pivot Table



You can learn more and see a Live demo at: http://www.viblend.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

olap | pivot | Silverlight | pivot grid | olap grid

About the author

Some text that describes me

Recent comments

None

Copyright © 2009 VIBlend  
ALL RIGHTS RESERVED  
 
Terms of Use | Privacy Policy
WinForms Controls Purchase Online About Us
       
DataGrid Navigation Pane Technical Support Blog
ScrollBar TreeView
ListBox ProgressBar Downloads Register
ComboBox Buttons
TabControl Editors Documentation Client Login

VIBlend Blog is powered by BlogEngine.NET