If you used windows 7, heard or saw some videos about it, then the most noticed change you might have noticed is the new taskbar and the cool functionalities it offers. Today I’ll show a little application that looks close to the Gmail Notifier Plus. The application can be customized to show any feeds that have the same structure as the (title, description, author, date) pattern, a great example would be the Twitter or Facebook updates. Here I’m going to show Bloginto7 that reads Bloginy feeds.
This part demonstrates the new TaskbarItemInfo, the new progressbar and the new text properties introduced in the .NET 4.0, the next part will be about the code to retrieve feeds asynchronously, change the UI and the Progress state and value from code. The other parts will be about Jumplists.
Part 1 : XAML:
1.1 TaskbarItemInfo :
The new TaskbarItemInfo can be created directly easily using XAML, mainly inside the <Window.TaskbarItemInfo> you can configure the parameters of the Taskbar button of you application along with the ThumbButtons as well. Here is the complete XAML that is used to produce the UI shown in the picture :- <Window.TaskbarItemInfo>
- <TaskbarItemInfo x:Name="BlogIntoTakbar"
- Description="BlogInto"
- ProgressState="None"
- ProgressValue="0">
- <TaskbarItemInfo.ThumbButtonInfos>
- <ThumbButtonInfo x:Name="previous"
- Click="previous_Click"
- Description="Previous"
- ImageSource="..\Resources\previous.ico"/>
- <ThumbButtonInfo x:Name="browseFeed"
- Description="Open the feed in the browser"
- Click="browseFeed_Click"
- ImageSource="..\Resources\browse.png"/>
- <ThumbButtonInfo x:Name="next"
- Click="next_Click"
- Description="Next"
- ImageSource="..\Resources\next.ico"/>
- </TaskbarItemInfo.ThumbButtonInfos>
- </TaskbarItemInfo>
- </Window.TaskbarItemInfo>
The code is self explained, the TaskbarItemInfo has some properties from which you can see the ProgressState and ProgressValue and the Description which is the tooltip shown once you hover on the Button in the Taskbar. The TaskbarItemInfo has a collection called ThumbButtonInfos in which you add buttons and you can specify the icon, the event when clicked and the description etc…
1.2 The main UI:
When you first look at the Gmail Notifier Plus app, you might think you need some specific tools and libraries to design such UI, but it’s just a small miniature of hidden window on your desktop, let’s see how we can achieve this.We are going to wrap the whole UI inside a Grid with 3 rows, the top most is used for the Feed title, author and in my case votes, the middle row with be the content of the feed, and the last row will be for the date and the range of the feeds (3rd from 15 for example).
This is how it looks like, a little ugly on the real form, but on the Taskbar, it is exactly what we want
The code of the Grid is the following, I’ll go through the new stuff one by one to show how things works (If you tried such design in WinForms or even other technologies, you will thank God WPF is here :) )
- <Grid Margin="10,0,5,5" ShowGridLines="True">
- <Grid.RowDefinitions>
- <RowDefinition Height="32*"/>
- <RowDefinition Height="2"/>
- <RowDefinition Height="58*"/>
- <RowDefinition Height="15*"/>
- </Grid.RowDefinitions>
- <StackPanel Grid.Row="0" Margin="0,0,0,5" TextOptions.TextFormattingMode="Ideal">
- <TextBlock Name="FeedTitle" Foreground="Blue" TextTrimming="CharacterEllipsis" FontStretch="ExtraExpanded" FontSize="36" Text="Title goes here"/>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="75*"/>
- <ColumnDefinition Width="15*"/>
- <ColumnDefinition Width="10*"/>
- </Grid.ColumnDefinitions>
- <Viewbox Stretch="Uniform" HorizontalAlignment="Left" Height="45" Grid.Column="0">
- <TextBlock Name="FeedAuthor" Foreground="#FF9D918F" Text="Feed author "/>
- </Viewbox>
- <TextBlock Grid.Column="1" Foreground="#FFFF2600" FontSize="28" Margin="0,18,5,0">Votes:</TextBlock>
- <Viewbox Stretch="Uniform" HorizontalAlignment="Left" Grid.Column="2" Height="55">
- <TextBlock Name="FeedVotes" Foreground="#FFFF2600" Text="10"/>
- </Viewbox>
- </Grid>
- </StackPanel>
- <TextBlock Grid.Row="1" Background="Black" HorizontalAlignment="Stretch" TextWrapping="WrapWithOverflow"/>
- <Viewbox Grid.Row="2">
- <TextBlock Name="NetworkError" Foreground="Red" TextWrapping="Wrap" FontStyle="Italic" Visibility="Hidden">Please check your network connection</TextBlock>
- </Viewbox>
- <TextBlock Name="FeedDescription" Grid.Row="2" TextWrapping="WrapWithOverflow" TextTrimming="CharacterEllipsis" FontSize="38"
- TextOptions.TextFormattingMode="Display" Margin="0,10,0,10" Text="Feed description goes here"/>
- <TextBlock Name="FeedDate" FontSize="32" Grid.Row="3" Margin="0,5,0,0" Foreground="#FF414141" TextOptions.TextFormattingMode="Ideal" Text="date : 12/12/12"/>
- <Viewbox Stretch="Uniform" Grid.Row="3" HorizontalAlignment="Right" TextOptions.TextFormattingMode="Ideal">
- <TextBlock Name="FeedRank" Foreground="#FF414141" Text="3/15"/>
- </Viewbox>
- </Grid>
This is it, the next part I’ll show the code to retrieve feeds asynchronously, change the UI and the Progress state and value from code.
You can find the XAML code here : http://pastie.org/718416, copy/paste it in the XAML of your windows, and you will get the UI working, no need for a line on code :)