Part I :Traffic Alert App – Take the pain out of driving

In the past few weeks I have creating some sample apps and in the next few weeks wou will get to see them. The first app is called TrafficAlert. Now as the name says it alerts you about traffic conditions. I have always had this problem of analyzing traffic maps because they show so many red, yellow green spots that its hard to get the details easily. So this app tries to do away with the analysis of the traffic maps. Rather it is one level higher and it provides a list view of the traffic conditions grouped as highways. Consequently you get a better perspective and hence, you can plan your driving route much more easily. Before talking anything more lets just have a look.

Image hosted by

This makes things a lot easier than explaining. 🙂 . Now that we have seen it lets dive into the code.

We begin with creating a simple WinFX Windows app which provides with an App.xaml and a Window1.xaml file along with their associated .cs files. Now the entire code goes into the Window1 files. So in this post lets have a look at the UI and in the subsequent post we'll look at the code behind it. 🙂


<Window x:Class="trafic.Window1"



Title="Traffic Alert"



Name ="w1"




Height ="700"



<StackPanel Name="sp">




      <Rectangle Stroke="black" Fill="orangered" Height="12" Width="12"/>


      <Rectangle Stroke="black" Fill="Orange" Height="12" Width="12"/>


      <Rectangle Stroke="black" Fill="Yellow" Height="12" Width="12"/>


      <Button Name="ZipCode" Click="ButtonClick">


               <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">



                        <GradientStop Color="red" Offset="0" />

                        <GradientStop Color="yellow" Offset="1" />








   <Label Name="Location" FontWeight="bold"/>

   <ScrollViewer HorizontalScrollBarVisibility="auto"
VerticalScrollBarVisibility="hidden" Name="sv">

      <TreeView Name="tv" BorderThickness="0" SizeChanged="tv_SizeChanged">




                  <Point X="0" Y="0"/>



                  <Point X="1" Y="1"/>



                     <GradientStop Color="red" Offset="0"/>

                     <GradientStop Color="black" Offset="1.15"/>








Pretty simple huh! Theres nothing much to it except for the use of gradientBrushes. This gives a very polished look to the app.

The first gradient brush is applied to the button and it is from top to bottom while the one applied to the treeView is diagonal.
This is based on the StartPoint and EndPoint. We have a sizeChanged event on the treeView and that basically is used to resize the window so that scrollbars are used minimally.

And one more thing, this is not a perfect app - so we can have further modifications. But one thing is sure - it works!! and thats what
counts in a sample app 😉

Ciao until the next post


Comments (2)

  1. I think you really need to change those colors. Red-Black gradient as an application background is very harsh….

  2. I agree that to some it may appear harsh. But changing it is not much pain either. The idea here is to show how a color gradient can be acheived.

    PS: I did think of having a color customization feature for the reason you mentioned. Alas, the shortage of time 😉

Skip to main content