Posted by: Zeeshan Amjad | October 30, 2009

Bitmap Effect on UIElement


Let’s take a look at Bitmap effect on our control. All bitmap effects are inherited by a class name BitmapEffect. Let’s take a look at first example of Our glow effect. Here is  a partial class diagram of BitmapEffect.

BitmapEffect

Here is the XAML code of this.

  1: <Window x:Class="UIElement.Window1"
  2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4:     xmlns:local="clr-namespace:UIElement"
  5:     Title="Diagonal List Box" Height="300" Width="300">
  6:     <Grid>
  7:         <Grid.LayoutTransform>
  8:             <RotateTransform Angle="45"/>
  9:         </Grid.LayoutTransform>
 10:         
 11:         <ListBox Name="list" Margin="5">
 12:             <ListBox.BitmapEffect>
 13:                 <OuterGlowBitmapEffect GlowColor="Blue" Noise="5" GlowSize="25"/>
 14:             </ListBox.BitmapEffect>
 15:         </ListBox>
 16:     </Grid>
 17: </Window>
 18: 

and here is the C# code of this program.

  1: using System;
  2: using System.Collections.Generic;
  3: using System.Linq;
  4: using System.Text;
  5: using System.Windows;
  6: using System.Windows.Controls;
  7: using System.Windows.Data;
  8: using System.Windows.Documents;
  9: using System.Windows.Input;
 10: using System.Windows.Media;
 11: using System.Windows.Media.Imaging;
 12: using System.Windows.Navigation;
 13: using System.Windows.Shapes;
 14: 
 15: namespace UIElement
 16: {
 17:     /// <summary>
 18:     /// Interaction logic for Window1.xaml
 19:     /// </summary>
 20:     public partial class Window1 : Window
 21:     {
 22:         public List<String> items
 23:         { get; set; }
 24: 
 25:         public Window1()
 26:         {            
 27:             InitializeComponent();
 28: 
 29:             items = new List<string>();
 30:             items.Add("Maryland");
 31:             items.Add("California");
 32:             items.Add("Taxes");
 33:             items.Add("Washington");
 34:             items.Add("Virginia");
 35: 
 36:             list.ItemsSource = items;
 37:         }
 38:     }
 39: }
 40: 

Here is the output of this program.

OuterGlowEffect

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: