VIBlend
Home Products Downloads Purchase Support Forum About Blog

How to style the standard WPF Button?

by viblend 30. September 2010 05:50

If you want to customize the appearance of the standard WPF Button with our Free Office 2010 Blue, Black and Silver themes for WPF then you need to do the following:

1. Add a reference to the Theme assembly.  In Solution Explorer, right-click on the project node and click Add Reference. Browse to the VIBlend.WPF.Theme.Office2010Black.dll, VIBlend.WPF.Theme.Office2010Blue.dll or VIBlend.WPF.Theme.Office2010Silver.dll and click the ‘OK’ button.
2. Drag and drop a Button control from the VS toolbox.
3.  Load the Theme resources and set the Style property of the Button control.

 <Window x:Class="WpfApplication98.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <ResourceDictionary Source="/VIBlend.WPF.Theme.Office2010Blue;component/Button.xaml"/>
    </Window.Resources>
    <Grid>
           <Button Content="Office 2010 Blue" Style="{StaticResource Office2010BlueButtonStyle}" Height="30" Name="button1" Width="125" />
    </Grid>
</Window>

VIBlend Silverlight Controls v3.0 - Released

by viblend 14. September 2010 20:47

VIBlend is announcing the immediate availability of the VIBlend Controls for Silverlight ver. 3.0.

With 19 new controls, Themes and enhanced functionality in the DataGrid, Menu and SpinEditor, VIBlend Controls for Silverlight empower developers to build full featured and great looking line-of-business applications.

New features:

  • Menu and ContextMenu controls now have 17 built-in Themes including Office 2010 Blue, Black and Silver and Office 2007 Blue, Black and Silver
  • DataGrid Enhancements  - The latest release introduces Export to Excel, CSV, HTML and XML.
  • 19 new editors such as ComboBox, ListBox, CheckedListBox, GroupBox, ColorPicker, RadioButton, CheckBox, Slider, Button, ToggleButton, etc.
  • Data Input Editors and NavigationPane now have an improved Data Binding capabilities.
See our Silverlight Controls Live Demo and Download a free trial today.

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

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