VIBlend
Home Products Downloads Purchase Support Forum About Blog

VIBlend Silverlight Controls 6.5

by viblend 19. August 2012 16:54

We are happy to announce the availability of VIBlend Controls for Silverlight ver. 6.5. The new version includes multiple bug fixes and small improvements to the existing features and themes of the package. 

  

Filter Silverlight DataGrid data programmatically

by viblend 10. July 2012 16:22
In order to achieve this, you need to follow the steps below:
 
1. Create DataGrid’s Rows, Columns and fill it with sample data. 
 
C#

for (int i = 0; i < 20; i++)
{
    this.dataGrid1.ColumnsHierarchy.Items.Add("Column " + i);
    this.dataGrid1.RowsHierarchy.Items.Add("Row " + i);
}

this.dataGrid1.AllowContextMenuFiltering = true;
this.dataGrid1.AllowContextMenuSorting = true;
Random random = new Random();

for (int i = 0; i < 20; i++)
{
    HierarchyItem row = this.dataGrid1.RowsHierarchy.Items[i];
    for (int j = 0; j < 20; j++)
    {
        HierarchyItem column = this.dataGrid1.ColumnsHierarchy.Items[j];
        column.AllowFiltering = true;
        this.dataGrid1.CellsArea.SetCellValue(row, column, (double)i);
    }
}

this.dataGrid1.ColumnsHierarchy.AutoResize(AutoResizeMode.FIT_ALL);
this.dataGrid1.RowsHierarchy.AutoResize(AutoResizeMode.FIT_ALL);

VB .NET

For i As Integer = 0 To 19
    Me.dataGrid1.ColumnsHierarchy.Items.Add("Column " & i)
    Me.dataGrid1.RowsHierarchy.Items.Add("Row " & i)
Next i

Me.dataGrid1.AllowContextMenuFiltering = True
Me.dataGrid1.AllowContextMenuSorting = True
Dim random As New Random()

For i As Integer = 0 To 19
    Dim row As HierarchyItem = Me.dataGrid1.RowsHierarchy.Items(i)
    For j As Integer = 0 To 19
        Dim column As HierarchyItem = Me.dataGrid1.ColumnsHierarchy.Items(j)
        column.AllowFiltering = True
        Me.dataGrid1.CellsArea.SetCellValue(row, column, CDbl(i))
    Next j
Next i

Me.dataGrid1.ColumnsHierarchy.AutoResize(AutoResizeMode.FIT_ALL)
Me.dataGrid1.RowsHierarchy.AutoResize(AutoResizeMode.FIT_ALL)
 
2. Create a new NumericFilter and set its ComparisonOperator and Value properties
 
C#

NumericFilter filter = new NumericFilter();
filter.ComparisonOperator = NumericComparisonOperator.GREATER_THAN;
filter.Value = 5;
FilterGroup<double?> filterGroup = new FilterGroup<double?>();
filterGroup.AddFilter(FilterOperator.AND, filter);

VB .NET

Dim filter As New NumericFilter()
filter.ComparisonOperator = NumericComparisonOperator.GREATER_THAN
filter.Value = 5
Dim filterGroup As FilterGroup(Of Nullable(Of Double)) = New FilterGroup(Of Nullable(Of Double))()
filterGroup.AddFilter(FilterOperator.AND, filter)

3. Create a new HierarchyItemFilter object and add the FilterGroup to it. 
 
C#

HierarchyItemFilter itemFilter = new HierarchyItemFilter();
itemFilter.Item = this.dataGrid1.ColumnsHierarchy.Items[0];
itemFilter.Filter = filterGroup;

VB .NET

Dim itemFilter As New HierarchyItemFilter()
itemFilter.Item = Me.dataGrid1.ColumnsHierarchy.
itemFilter.Filter = filterGroup
 
4. Finally, add the HierarchyItemFilter instance to the Filters collection of the DataGrid’s RowsHierarchy. 
 
C#

this.dataGrid1.RowsHierarchy.Filters.Add(itemFilter);

VB .NET

Me.dataGrid1.RowsHierarchy.Filters.Add(itemFilter)
 

VIBlend Silverlight Controls 6.0 With New Metro UI Themes

by viblend 18. January 2012 16:47

We are happy to announce the availability of VIBlend Silverlight Controls 6.0.  The newest version of VIBlend Silverlight Controls includes a set of new Metro UI Themes - Metro Blue, Metro Green and Metro Orange themes.

To download an evaluation version, please visit our Download page. 

View the updated Online Demo.

 

VIBlend Silverlight Controls 5.1

by viblend 29. September 2011 18:22
The updated version of VIBlend Silverlight Controls has just came out. 
  
What's New: 
 
DataGrid Columns Chooser.
DataGrid Grouping Headers Renderer.
Added support for Silverlight 5 RC.
 
What's Fixed:
 
Resolved an issue regarding the DataGrid scrolling.
Resolved an issue regarding the DataGrid HierarchyItem's rendering.
Resolved an issue regarding the HierarchyItem Templates.
Resolved an issue regarding the DataGrid data binding.
Resolved an issue regarding the DataGrid Dispose logic.
Resolved an issue regarding the DataGrid localization.
Resolved an issue regarding the Scheduler repeating appointments.
Resolved an issue regarding the Scheduler day view rendering.
Resolved an issue regarding the Scheduler Appointment dialog.
Resolved an issue regarding the Scheduler resources binding.
Resolved an issue regarding the Scheduler Appointments layout in Day View.
Resolved an issue regarding the DataTimePicker's date formatting.
Resolved an issue regarding the ComboBox selection. 

Working with the VIBlend DataGrid and Nested Data Structures

by viblend 8. June 2011 22:29

This example demonstrates how to bind the VIBlend DataGrid for Silverlight to a list of invoices that has nested properties. The schema of data source contains the following DataFields / Properties: SalesPerson(string), ShipperCompany(string), ProductName(string), UnitPrice(double),
Quantity(double), Discount(double), ExtendedPrice(double), Freight(double) and Address(Address). The address object has the following properties: City(string), Region(string) and Country(string).

We'll create a Pivot Table with 3 pivot rows - City, Country and Region and 1 pivot column - Shipper Company.

<viblend:DataGrid ItemsSource="{Binding}" x:Name="dataGrid1" Margin="4" Background="White" AutoGenerateColumns="True">
    <viblend:DataGrid.BoundFields>
        <viblend:BoundField Text="Country" DataField="Address.Country" Width="160" SortMode="NotSortable"/>
        <viblend:BoundField Text="City" DataField="Address.City" Width="140" SortMode="NotSortable"/>
        <viblend:BoundField Text="Region" DataField="Address.Region" Width="140" SortMode="NotSortable"/>
        <viblend:BoundField Text="Carrier" DataField="ShipperCompany" Width="140" SortMode="NotSortable" />
        <viblend:BoundField Text="ExtendedPrice" DataField="ExtendedPrice" Width="140" SortMode="NotSortable" />
    </viblend:DataGrid.BoundFields>
    <viblend:DataGrid.BoundPivotRows>
        <viblend:BoundField Text="Country" DataField="Address.Country" Width="160" SortMode="NotSortable"/>
        <viblend:BoundField Text="Region" DataField="Address.Region" Width="160" SortMode="NotSortable"/>
        <viblend:BoundField Text="City" DataField="Address.City" Width="140" SortMode="NotSortable"/>
    </viblend:DataGrid.BoundPivotRows>
    <viblend:DataGrid.BoundPivotColumns>
        <viblend:BoundField Text="Carrier" DataField="ShipperCompany" Width="140" SortMode="NotSortable"/>
    </viblend:DataGrid.BoundPivotColumns>
    <viblend:DataGrid.BoundPivotValues>
        <viblend:BoundValueField Width="120" CellHorizontalContentAlignment="Center" Text="Count of Sales" Function="Count" DataField="ExtendedPrice"></viblend:BoundValueField>
         <viblend:BoundValueField Width="120" CellHorizontalContentAlignment="Right" CellVerticalContentAlignment="Center" CellTextFormatString="{}{0:C}" Text="Amount of Sales" Function="Sum" DataField="ExtendedPrice"></viblend:BoundValueField>
        <viblend:BoundValueField Width="120" CellHorizontalContentAlignment="Right" CellVerticalContentAlignment="Center" CellTextFormatString="{}{0:C}" Text="Avg Sale Amount" Function="Average" DataField="ExtendedPrice"></viblend:BoundValueField>
    </viblend:DataGrid.BoundPivotValues>
</viblend:DataGrid>

The following code generates the sample data in the example:

C#

public PivotTableDemo()
{
    InitializeComponent();
    PrepareGridData();
    this.DataContext = this.lst;
}

public class Invoice
{
    public Invoice(
        string City,
        string Region,
        string Country,
        string SalesPerson,
        string ShipperCompany,
        string ProductName,
        double UnitPrice,
        double Quantity,
        double Discount,
        double ExtendedPrice,
        double Freight)
    {
        this.SalesPerson = SalesPerson;
        this.Address = new Address();
        this.Address.City = City;
        this.Address.Region = string.IsNullOrEmpty(Region) ? "All Regions" : Region;
        this.Address.Country = Country;
        this.ShipperCompany = ShipperCompany;
        this.ProductName = ProductName;
        this.UnitPrice = UnitPrice;
        this.Quantity = Quantity;
        this.Discount = Discount;
        this.ExtendedPrice = ExtendedPrice;
        this.Freight = Freight;
    }

    public string SalesPerson { get; set; }
    public string ShipperCompany { get; set; }
    public Address Address { get; set; }
    public string ProductName { get; set; }
    public double UnitPrice { get; set; }
    public double Quantity { get; set; }
    public double Discount { get; set; }
    public double ExtendedPrice { get; set; }
    public double Freight { get; set; }
}

public class Address
{
    public string City { get; set; }
    public string Region { get; set; }
    public string Country { get; set; }
}

public List<Invoice> lst = new List<Invoice>();
private void PrepareGridData()
{
    try
    {
        StreamResourceInfo sri = Application.GetResourceStream(new Uri("IntegratedDemo;component/Examples/Grid/invoices.tab", UriKind.Relative));
        System.IO.StreamReader sr = new System.IO.StreamReader(sri.Stream);
        string line = null;
        sr.ReadLine();
        while ((line = sr.ReadLine()) != null)
        {
            string[] tabs = line.Split('\t');
            lst.Add(new Invoice(tabs[0], tabs[1], tabs[2], tabs[3], tabs[4], tabs[5], double.Parse(tabs[6]), double.Parse(tabs[7]), double.Parse(tabs[8]), double.Parse(tabs[9]), double.Parse(tabs[10])));
        }
        sr.Close();
    }
    catch (System.Exception)
    {
    }
}

VB .NET

Public Sub New()
    InitializeComponent()
    PrepareGridData()
    Me.DataContext = Me.lst
End Sub

Public Class Invoice
    Public Sub New(ByVal City As String, ByVal Region As String, ByVal Country As String, ByVal SalesPerson As String, ByVal ShipperCompany As String, ByVal ProductName As String, ByVal UnitPrice As Double, ByVal Quantity As Double, ByVal Discount As Double, ByVal ExtendedPrice As Double, ByVal Freight As Double)
        Me.SalesPerson = SalesPerson
        Me.Address = New Address()
        Me.Address.City = City
        Me.Address.Region = If(String.IsNullOrEmpty(Region), "All Regions", Region)
        Me.Address.Country = Country
        Me.ShipperCompany = ShipperCompany
        Me.ProductName = ProductName
        Me.UnitPrice = UnitPrice
        Me.Quantity = Quantity
        Me.Discount = Discount
        Me.ExtendedPrice = ExtendedPrice
        Me.Freight = Freight
    End Sub

    Private privateSalesPerson As String
    Public Property SalesPerson() As String
        Get
            Return privateSalesPerson
        End Get
        Set(ByVal value As String)
            privateSalesPerson = value
        End Set
    End Property
    Private privateShipperCompany As String
    Public Property ShipperCompany() As String
        Get
            Return privateShipperCompany
        End Get
        Set(ByVal value As String)
            privateShipperCompany = value
        End Set
    End Property
    Private privateAddress As Address
    Public Property Address() As Address
        Get
            Return privateAddress
        End Get
        Set(ByVal value As Address)
            privateAddress = value
        End Set
    End Property
    Private privateProductName As String
    Public Property ProductName() As String
        Get
            Return privateProductName
        End Get
        Set(ByVal value As String)
            privateProductName = value
        End Set
    End Property
    Private privateUnitPrice As Double
    Public Property UnitPrice() As Double
        Get
            Return privateUnitPrice
        End Get
        Set(ByVal value As Double)
            privateUnitPrice = value
        End Set
    End Property
    Private privateQuantity As Double
    Public Property Quantity() As Double
        Get
            Return privateQuantity
        End Get
        Set(ByVal value As Double)
            privateQuantity = value
        End Set
    End Property
    Private privateDiscount As Double
    Public Property Discount() As Double
        Get
            Return privateDiscount
        End Get
        Set(ByVal value As Double)
            privateDiscount = value
        End Set
    End Property
    Private privateExtendedPrice As Double
    Public Property ExtendedPrice() As Double
        Get
            Return privateExtendedPrice
        End Get
        Set(ByVal value As Double)
            privateExtendedPrice = value
        End Set
    End Property
    Private privateFreight As Double
    Public Property Freight() As Double
        Get
            Return privateFreight
        End Get
        Set(ByVal value As Double)
            privateFreight = value
        End Set
    End Property
End Class

Public Class Address
    Private privateCity As String
    Public Property City() As String
        Get
            Return privateCity
        End Get
        Set(ByVal value As String)
            privateCity = value
        End Set
    End Property
    Private privateRegion As String
    Public Property Region() As String
        Get
            Return privateRegion
        End Get
        Set(ByVal value As String)
            privateRegion = value
        End Set
    End Property
    Private privateCountry As String
    Public Property Country() As String
        Get
            Return privateCountry
        End Get
        Set(ByVal value As String)
            privateCountry = value
        End Set
    End Property
End Class

Public lst As List(Of Invoice) = New List(Of Invoice)()
Private Sub PrepareGridData()
    Try
        Dim sri As StreamResourceInfo = Application.GetResourceStream(New Uri("IntegratedDemo;component/Examples/Grid/invoices.tab", UriKind.Relative))
        Dim sr As New System.IO.StreamReader(sri.Stream)
        Dim line As String = Nothing
        sr.ReadLine()
        line = sr.ReadLine()
        Do While line IsNot Nothing
            Dim tabs() As String = line.Split(ControlChars.Tab)
            lst.Add(New Invoice(tabs(0), tabs(1), tabs(2), tabs(3), tabs(4), tabs(5), Double.Parse(tabs(6)), Double.Parse(tabs(7)), Double.Parse(tabs(8)), Double.Parse(tabs(9)), Double.Parse(tabs(10))))
            line = sr.ReadLine()
        Loop
        sr.Close()
    Catch e1 As System.Exception
    End Try
End Sub


Note: The 'invoices.tab' file is included in the installation package of VIBlend Controls for Silverlight. The default path to the file is: C:\Program Files\VIBlend\SilverlightControls v.5.0\Source Code\CSharp\Examples\Grid\invoices.tab.

New ChildWindow control coming to VIBlend Silverlight Controls v5.0

by viblend 21. April 2011 19:38

In the next version of VIBlend Controls for Silverlight, we will introduce a new control - Silverlight ChildWindow. The ChildWindow control allows you to direct a user’s attention to a particular activity in your application such as entering data or viewing information. This new control resembles a standard Window and can be displayed in a modal or non-modal popup. When the control is displayed in a modal mode, the interaction with the underlying user interface is blocked.

Built-In Features:

  • Animated Open and Close Effects - the window is opened and closed with a smooth animation.
  • Resizing Support - users can choose to drag edges to resize the window.
  • Modal Mode - when the window is opened in a modal mode, the end-users cannot access any part of the interface outside of the dialog.
  • Non-Modal Mode - this mode enables the end-users to access the application's user interface.
  • Startup Position - you can choose the window's startup position. By default, the window is started at the application's middle-center.
  • Minimized and Maximized states - the window can be maximized or minimized similar to the standard Windows.
  • Application Boundaries Detection - end-users cannot drag or resize the window outside of the application's boundaries.

VIBlend Controls for Silverlight v4.0.0 - Released

by viblend 2. February 2011 17:02

We are proud to announce the immediate availability of VIBlend Silverlight Controls v4.0.0 - the next generation of user interface controls for Silverlight from VIBlend.

Highlights of the new features and improvements in the new version are:

  • Smooth scrolling animation in TreeView, ListBox, ComboBox and CheckedListBox,
  • DataGrid Pivot table aggregation functions - StDev, StDevP, Var, VarP ,
  • New Controls: Ribbon Bar, vScrollViewer, DataGrid Pivot Design Panel, DataGrid Grouping Panel
  • New Default Theme for all controls in the package.

 

To help you shorten your learning curve we improved our help documentation, provide the style definitions of our themes and the full source code in C# and VB .NET of our examples.

Using a Context Menu with a TreeView

by viblend 14. November 2010 01:44

This blog post demonstrates how to capture the right click event on a tree view in order to display a context menu.

At first, we need to drag and drop a new instances of the TreeView and ContextMenu controls from the Visual Studio 2010 Toolbox.


 

The xaml markup is shown below:

<UserControl x:Class="TreeViewContextMenu.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="300" d:DesignWidth="400" xmlns:viblendTreeView="clr-namespace:VIBlend.Silverlight.Controls;assembly=VIBlend.Silverlight.TreeView" xmlns:viblendMenu="clr-namespace:VIBlend.Silverlight.Controls;assembly=VIBlend.Silverlight.Menu">

    <Grid x:Name="LayoutRoot" Background="White">
        <viblendTreeView:TreeView Height="250" HorizontalAlignment="Center"  Name="treeView1" VerticalAlignment="Center" Width="200">
            <viblendTreeView:TreeViewItem DisplayValue="Tree Item 1" IsExpanded="True">
                <viblendTreeView:TreeViewItem DisplayValue="Tree Sub Item 1" />
                <viblendTreeView:TreeViewItem DisplayValue="Tree Sub Item 2" />
                <viblendTreeView:TreeViewItem DisplayValue="Tree Sub Item 3" />
            </viblendTreeView:TreeViewItem>
            <viblendTreeView:TreeViewItem DisplayValue="Tree Item 2" />
        </viblendTreeView:TreeView>
        <viblendMenu:ContextMenu HorizontalAlignment="Left"  Name="contextMenu1" VerticalAlignment="Top">   
            <viblendMenu:MenuItem Click="AddItem_Click" Text="Add" />
            <viblendMenu:MenuItem Click="RemoveItem_Click" Text="Remove" />
            <viblendMenu:MenuItem Click="DisplayItem_Click" Text="Disable" />
         </viblendMenu:ContextMenu>
    </Grid>
</UserControl>

Then we need to subscribe to the MouseRightButtonDown event and we can do this either in the xaml markup or in code-behind:

C#

this.MouseRightButtonDown += new MouseButtonEventHandler(MainPage_MouseRightButtonDown); 

VB .NET

AddHandler MouseRightButtonDown, AddressOf MainPage_MouseRightButtonDown

After we subscribe to the MouseRightButtonDown event, we should implement its event handler. In the event handler, we display the ContextMenu control on the position where the right mouse button is clicked.

C#

void MainPage_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
   Point point = e.GetPosition(this.treeView1);
   if (point.X >= 0 && point.X <= this.treeView1.Width)
   {
       if (point.Y >= 0 && point.Y <= this.treeView1.Height)
       {
           Point contextMenuLocation = e.GetPosition(this);
           this.contextMenu1.Open(contextMenuLocation);
           e.Handled = true;
       }
   }
}

VB .NET

Private Sub MainPage_MouseRightButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
   Dim point As Point = e.GetPosition(Me.treeView1)
   If point.X >= 0 AndAlso point.X <= Me.treeView1.Width Then
      If point.Y >= 0 AndAlso point.Y <= Me.treeView1.Height Then
          Dim contextMenuLocation As Point = e.GetPosition(Me)
          Me.contextMenu1.Open(contextMenuLocation)
          e.Handled = True
       End If
   End If
End Sub

Finally, we implement the event handlers that will add, remove and disable TreeViewItem objects.

C#

private void AddItem_Click(object sender, EventArgs e)
{
    if (this.treeView1.SelectedItem != null)
    {
        TreeViewItem item = new TreeViewItem("New Item");
        this.treeView1.SelectedItem.Items.Add(item);
    }
}

private void RemoveItem_Click(object sender, EventArgs e)
{
    if (this.treeView1.SelectedItem != null)
    {
        if (this.treeView1.SelectedItem.ParentTreeViewItem != null)
        {
            this.treeView1.SelectedItem.ParentTreeViewItem.Items.Remove(this.treeView1.SelectedItem);
        }
        else if (this.treeView1.Items.Contains(this.treeView1.SelectedItem))
        {
            this.treeView1.Items.Remove(this.treeView1.SelectedItem);
        }
    }
}

private void DisableItem_Click(object sender, EventArgs e)
{
    if (this.treeView1.SelectedItem != null)
    {
        this.treeView1.SelectedItem.IsEnabled = false;
    }
}

VB .NET

Private Sub AddItem_Click(ByVal sender As Object, ByVal e As EventArgs)
    If Me.treeView1.SelectedItem IsNot Nothing Then
        Dim item As New TreeViewItem("New Item")
        Me.treeView1.SelectedItem.Items.Add(item)
    End If
End Sub

Private Sub RemoveItem_Click(ByVal sender As Object, ByVal e As EventArgs)
    If Me.treeView1.SelectedItem IsNot Nothing Then
        If Me.treeView1.SelectedItem.ParentTreeViewItem IsNot Nothing Then
            Me.treeView1.SelectedItem.ParentTreeViewItem.Items.Remove(Me.treeView1.SelectedItem)
        ElseIf Me.treeView1.Items.Contains(Me.treeView1.SelectedItem) Then
            Me.treeView1.Items.Remove(Me.treeView1.SelectedItem)
        End If
    End If
End Sub

Private Sub DisableItem_Click(ByVal sender As Object, ByVal e As EventArgs)
    If Me.treeView1.SelectedItem IsNot Nothing Then
        Me.treeView1.SelectedItem.IsEnabled = False
    End If
End Sub

Here is the result:

VIBlend Silverlight Controls v3.5 - Released

by viblend 1. November 2010 03:14

We are proud to announce the availability of VIBlend Controls for Silverlight ver. 3.5.0 - the next generation of user interface controls for Silverlight from VIBlend. Our main efforts for this release were focused on improving the DataGrid’s rendering and performance.

Highlights of the new features and improvements in the new version are:

  • DataGrid performance optimizations
  • New themes for all VIBlend Controls for Silverlight
  • New controls - TabControl, Toolbar and BannerRotator
  • Design Time improvements 

To help you create themes and skins for your applications, we added a new ‘CustomTheme’ project to our installation package. This project includes C# and VB .NET samples and xaml style definitions for our controls.



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

VIBlend Controls for Silverlight ver. 2.6 - Released

by viblend 21. June 2010 20:37

VIBlend is pleased to announce the immediate availability of VIBlend Controls for Silverlight ver. 2.6. The new version includes several important updates to the company's Silverlight suite.

 Highlights of the new features and improvements in the new version are:

  • Visual Studio 2010 toolbox integration
  • Right Click support in DataGrid
  • DataGrid sorting and filtering using a Context Menu
  • DataGrid performance optimizations
  • Improved DataGrid Office2010 themes
  • Turned off DataGrid deferred scrolling feature by default.
  • Fixed a design time issue in the Menu control.
  • Fixed a design time issue in the TreeView control.
  • Fixed a Stretch alignment issue in the DataGrid control.

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

About the author

Some text that describes me

Tag cloud

Recent comments

Comment RSS
Copyright © 2011 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