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

What's new in VIBlend DataGridView for WinForms?

by viblend 13. July 2010 09:20

In the latest release of VIBlend Controls for WinForms, we introduced several new features in our DataGridView control. These are the Rows Grouping panel and the Column Chooser. The main purpose of the Rows Grouping panel is to allow you to easily group/ungroup columns via a built-in drag and drop and to visually represent the grouped columns.


The Column Chooser is an additional small feature which allows you to manage the visibility of your columns.  In order to activate the column chooser, set the EnableColumnChooser property to true. To show the column chooser, use the ShowColumnChooser method. If you want to hide it, use the HideColumnChooser method.



Another improvement in the DataGridView is the extended functionality of the ComboBox and DateTimePicker editors. Their pop up controls are now automatically opened when the editor is activated.  If you want to disable this feature, you can set the AutoOpenEditorOnActivation property of the editor to false.

Currently rated 3.3 by 4 people

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

Tags: , ,

DataGrid | WinForms | winforms grid

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.

Currently rated 4.7 by 3 people

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

Tags: , , ,

Silverlight | Silverlight Controls

VIBlend WPF DateTimeEditor and Data binding

by viblend 5. June 2010 08:58

This blog post illustrates how you can use the VIBlend WPF DateTimeEditor control in data binding scenarios.

The following is a complete sample, ready to run once you have copied it to your project.

At first, create a new WPF application and add a reference to the VIBlendWPFEditors.dll. Then add a new DateTimeEditor and ListBox controls in your application’s window. After that, bind the DateTimeEditor’s Value as well as the ListBox’s SelectedValue to a property named DateTimeValue.

XAML
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viblend="clr-namespace:VIBlend.WPF.Controls;assembly=VIBlendWPFEditors"
        xmlns:local="clr-namespace:WpfApplication1"
        Title="MainWindow" Height="200" Width="300">
    <Grid x:Name="LayoutRoot" Height="200" Width="300">
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <viblend:DateTimeEditor Grid.Row="1" Value="{Binding DateTimeValue, Mode=TwoWay}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="100" Height="20"></viblend:DateTimeEditor>
         <ListBox Grid.Column="1" Grid.Row="1" SelectedValue="{Binding DateTimeValue, Mode=TwoWay}" Height="110" HorizontalAlignment="Left"  Name="listBox1" VerticalAlignment="Top" Width="130"/>
        <Label Content="DateTime Items" Grid.Column="1" Height="28" HorizontalAlignment="Left" Name="label1" VerticalAlignment="Top" />
        <Label Content="DateTime Editor" Height="28" HorizontalAlignment="Left" Name="label2" VerticalAlignment="Top" />
    </Grid>
</Window>

The next step is to create a class which defines the DateTimeValue property.    

        public class DataBindingData : INotifyPropertyChanged
        {    
            private DateTime dateTime = new DateTime(2010, 06, 06);
            public DataBindingData()
            {
            }

            public DateTime DateTimeValue
            {
                get
                {
                    return this.dateTime;
                }
                set
                {
                    this.dateTime = value;
                    this.OnPropertyChanged("DateTimeValue");
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;
            protected virtual void OnPropertyChanged(string name)
            {
                if (this.PropertyChanged != null)
                {
                    this.PropertyChanged(this, new PropertyChangedEventArgs(name));
                }
            }
      }


The final step is to fill the ListBox with DateTime items and to set the DataContext property of the LayoutRoot object. This is implemented in the MainWindow’s constructor, after the InitializeComponent call.           

            this.LayoutRoot.DataContext = new DataBindingData();
            List<DateTime> dateTimeList = new List<DateTime>();
            dateTimeList.Add(new DateTime(2010, 06, 06));
            dateTimeList.Add(new DateTime(2010, 06, 07));
            dateTimeList.Add(new DateTime(2010, 06, 08));
            dateTimeList.Add(new DateTime(2010, 06, 09));
            dateTimeList.Add(new DateTime(2010, 06, 10));
            this.listBox1.ItemsSource = dateTimeList;


The image below represents our sample’s main window. When you select a value from the ListBox, the DateTimeEditor’s Value will be changed and vice versa.

Be the first to rate this post

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

Tags: , , ,

WPF Editors, WPF

VIBlend Controls for Silverlight 4.0 - Released

by viblend 21. May 2010 12:02

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

Our main efforts for this release were focused on the Silverlight 4.0 and Visual Studio 2010 support. Another major improvement is the availability of three new themes - Office 2010 Blue, Office 2010 Black and Office 2010 Silver.

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: , , , ,

How to create a scrollable Menu in Silverlight

by viblend 8. May 2010 18:30

In case the available height is too small to accommodate a group of menu items, the group becomes scrollable.  Each menu item has a DropDownHeight and VerticalScrollBarVisibility properties. The DropDownHeight property is used to restrict the displayed height of a group of menu items, while the VerticalScrollBarVisibility property defines whether the item allows vertical scrolling or not.

The following code example demonstrates how to create a scrollable menu.

[XAML]

         <viblend:Menu Name="Menu" Width="400" Height="20">
                <viblend:MenuItem RootNormalForeBrush="Black" DropDownHeight="150" VerticalScrollBarVisibility="Visible" Text="File">
                    <viblend:MenuItem Text="Mail Message" ImageSource="images/mail.png"/>
                    <viblend:MenuItem Text="Note" ImageSource="images/Note.png"/>
                    <viblend:MenuItem Text="Contact" ImageSource="images/contact.png" />
                    <viblend:MenuItem Text="Appointment" ImageSource="images/Appointment.png"/>
                    <viblend:MenuItem Text="Task" ImageSource="images/Task.png" />
                    <viblend:MenuItem Text="Folder" ImageSource="images/folder.png"/>
                </viblend:MenuItem>
            </viblend:Menu>

VIBlend Menu for Silverlight is a free component that is part of the VIBlend Controls for Silverlight package.

TabControl for WinForms Updates

by viblend 3. May 2010 15:53

With version 4.6 of VIBlend Controls for WinForms, we introduced several rendering and functionality improvements and made the look and feel of VIBlend vTabControl fully customizable. You can easily add custom drawing by handling the DrawTabPage, DrawTabPageBackground and DrawTitleBackground events. The screenshot below is from our FlexibleStyling example (full source code available in C# and VB.NET):

We also added an easy way to customize the Font and Color settings of TabPage’s Header. Take a look at the code snippet and screenshot of a TabPage with green text color and bold font style.

           C#

vTabPage tabPage = this.vTabControl1.TabPages[0];
tabPage.UseThemeTextColor = false;
tabPage.UseDefaultTextFont = false;
tabPage.PressedTextColor = Color.Green;
tabPage.TextFont = new Font(tabPage.Font, FontStyle.Bold);
VB .NET
Dim tabPage As vTabPage = Me.vTabControl1.TabPages(0)
tabPage.UseThemeTextColor = False
tabPage.UseDefaultTextFont = False
tabPage.PressedTextColor = Color.Green
tabPage.TextFont = New Font(tabPage.Font, FontStyle.Bold)

 

 

Be the first to rate this post

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

Tags: , , , , ,

TabControl | WinForms

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

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

How to add a control in OutlookPane for Silverlight

by viblend 23. March 2010 05:07

In the new release of VIBlend Controls for Silverlight, we added several new controls. One of them is the OutlookPane control. In this blog post we show you how to add any control as a content to it.

At first you need to add references to the NavigationPanes.dll, VIBlendUtilities.dll and Extensions.dll in order to use the OutlookPane and Calendar controls. Then you should create the DataTemplates for the OutlookPane items. The CalendarTemplate simply adds an Image on the left side of a TextBlock. In the source code below, this template is used to define the look of the OutlookPaneItem’s header. The other data template is the ShortCalendarTemplate which is used when the OutlookPaneItem is collapsed or  shown in the OutlookPane’s status area.  After the creation of the DataTemplates,  you should add a new instance of the OutlookPane control and insert a new OutlookPaneItem to it. Finally, put a new Calendar control as a content of the OutlookPaneItem.

Source Code:

<Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <DataTemplate x:Name="CalendarTemplate">
              <StackPanel Orientation="Horizontal">
                    <Image Margin="2" Width="18" HorizontalAlignment="Left" Height="18" Source="calendarIcon.png"></Image>
                    <TextBlock Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" FontWeight="Bold" Text="Calendar"></TextBlock>
            </StackPanel>
            </DataTemplate>
            <DataTemplate x:Name="ShortCalendarTemplate">
                <Image Margin="2" Width="18" HorizontalAlignment="Left" Height="18" Source="calendarIcon.png"></Image>
            </DataTemplate>     
        </Grid.Resources>
        <viblend:OutlookPane Width="250" Height="300" VerticalAlignment="Center" HorizontalAlignment="Center">
                <viblend:OutlookPaneItem IsSelected="True" MenuItemHeader="Calendar" CollapsedDefaultHeaderTemplate="{StaticResource ShortCalendarTemplate}" 
                                             CollapsedStatusContentTemplate="{StaticResource ShortCalendarTemplate}"
                                             DisplayHeader="Calendar"
                                             DefaultHeaderTemplate="{StaticResource CalendarTemplate}"
                                   >
                <toolkit:Calendar VerticalAlignment="Center" HorizontalAlignment="Center"></toolkit:Calendar>
            </viblend:OutlookPaneItem>
        </viblend:OutlookPane>
  </Grid>

Here is the result:

   

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