Sharker Khaleed Mahmud Silverlight Tips & Tricks

January 17, 2010

Tricks and Tips 13 : Apply Silverlight toolkit themes

For this case i will be using Silverlight 4 Beta toolkit in VS2010

You have to add two reference to use the toolkit.

Expression Dark Theme

C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Toolkit\Nov09\Themes\System.Windows.Controls.Theming.ExpressionDark.dll

C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Toolkit\Nov09\Bin\System.Windows.Controls.Theming.Toolkit.dll

MainPage.xaml

<UserControl xmlns:my=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data”  x:Class=”Tips.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:dark=”clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ExpressionDark”>

    <Grid x:Name=”LayoutRoot”>

        <dark:ExpressionDarkTheme>

            <StackPanel HorizontalAlignment=”Left”>

                <Button Width=”60″ Height=”30″ x:Name=”btnLoad” HorizontalAlignment=”Left” Content=”Test”/>   

                <my:DataGrid x:Name=”Datagrid” />

            </StackPanel>

        </dark:ExpressionDarkTheme>

    </Grid>

</UserControl>

MainPage.xaml.cs

using System.Collections.Generic;

using System.Windows;

using System.Windows.Controls;

namespace Tips

{

    public class Person

    {

        public string Title { get; set; }

        public string Position { get; set; }

        public string Status { get; set; }

        public string Education { get; set; }

        public string CurrentlyBusyWith { get; set; }

    }

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

            btnLoad.Click += new RoutedEventHandler(btnLoad_Click);

        }

        void btnLoad_Click(object sender, RoutedEventArgs e)

        {

            List<Person> coll = new List<Person>();

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            coll.Add(new Person { Title=”Sharker Khaleed Mahmud” , Position=”Web Developer”, Status=”Need H1B” , Education=”BSc.”, CurrentlyBusyWith=”Aiming for MVP” });

            coll.Add(new Person { Title = “Tom Cruise”, Position = “Actor”, Status = “Socializing”, Education = “No Idea”, CurrentlyBusyWith = “creating movie” });

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            coll.Add(new Person { Title = “Sample”, Position = “Sample”, Status = “Sample”, Education = “Sample”, CurrentlyBusyWith = “Sample” });

            Datagrid.ItemsSource = coll;

        }

    }

}

Sharker Khaleed Mahmud

Software Developer

(MCP,MCTS,MCPD[web])

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.