Create windows sidebar
Create Windows sidebar using Windows Presentation Foundation and Visual Studio 2008.
- Requirements
a. Windows Vista or Windows 7
b. .net framework 3.5
c. Visal studio 2008
- Steps
a. Start up the visual studio and create new wpf application.
b. From the solution exlporer panel open up the windows1.xaml file (default mail window created by vs while creating new project).
c. Remove the innner grid element and replace the top window element with grid element. Remove the title element on the main grid element.
Final code:
<Grid x:Class=”com.dot4pro.RssReader”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:cc=”clr-namespace:CatControls;assembly=CatControls”
Height=”600″ Width=”400″>
<Grid.Resources>
</Grid.Resources>
Your controls here.
</Grid>
d. Open up the app.xaml file and remove the StartupUri attribute, which looks like StartupUri=“Window1.xaml“
e. Open up the app.xaml.cs and override the OnStartUp function.
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MainWindow = new Window();
MainWindow.Background = System.Windows.Media.Brushes.Transparent;
MainWindow.AllowsTransparency = true;
MainWindow.WindowStyle = WindowStyle.None;
MainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
MainWindow.Content = new Window1();
MainWindow.SizeToContent = SizeToContent.WidthAndHeight;
MainWindow.MouseLeftButtonDown += delegate
{
MainWindow.DragMove();
};
MainWindow.ShowDialog();
}
This method will allow the Gadget content (here known as Window1) to be shown in an environment very similar to Windows Sidebar – a translucent window placeholder with dragging capabilities.
The Gadget manifest file
Gadget package contains a specific file (manifest file) that contains the information about Gadget such as name of the gadget, author, type, description etc. The name of the gadget file should be gadget.xml and should be as below.
<?xml version=”1.0″ encoding=”utf-16″?>
<gadget>
<name>Rss reader</name>
<namespace>com.dot4pro</namespace>
<version>1.0.0.0</version>
<author name=”Bedanand Sharma”>
<info url=”http://www.dot4pro.com” text=”www.dot4pro.com”/>
</author>
<copyright>© 2006</copyright>
<description>A sample rss reader</description>
<hosts>
<host name=”sidebar”>
<base type=”WPF“ apiVersion=”1.0.0″ src=”RssReader.exe” wpfClass=”rssreader.RssReader“/>
<permissions>Full</permissions>
<platform minPlatformVersion=”1.0″/>
</host>
</hosts>
</gadget>
- Create gadget package
i. Create a folder and put gadget.xml and all other executables, design files.
ii. Select all the file with in the folder and compress it and give it a meaningful name like rsssreader.gadget . Remember file extension should be .gadget instead of .zip file so that windows vista or 7 can handle it.






