I found this link that will allow you to download set of Metro icons for Windows Phone 7. You will need to scroll down closer to the bottom of the page to find the actual links.
Enjoy
I found this link that will allow you to download set of Metro icons for Windows Phone 7. You will need to scroll down closer to the bottom of the page to find the actual links.
Enjoy
I had a privilege to present on Silverlight development for Windows Phone 7 at local Atlanta.NET Users Group today, March 29th 2010.
You can download PowerPoint presentation here. Please email me any questions you have regarding the presentation.
Thanks.
In this post I will continue exploring Windows Phone 7 development. Almost any application needs a data source. There are a few options available for Silverlight applications on Windows Phone. You can use plain WCF service. You can optionally put it on Azure. You can also use Isolated Storage. Essentially it becomes your custom database. Of course, you have to write all the API in this case. Or, you can use OData. OData approach is the one I am exploring in this post.
First things first, you need to download CTP for OData on Windows Phone. Here is the link for this download:
Download and unzip the files into a folder. You will need a DLL that is contained in this download – System.Data.Services.Client.Dll
You can follow my previous post and create new Silverlight application for Windows Phone. There is small change you will need to make. You need to select the following project template:
Now we need to pick an OData source. I am going to look at www.OData.Org to find one. I am picking Mix 2010, but you can select any other. Here is the link I found on OData site – http://api.visitmix.com/OData.svc/
You can always browse the service. In my case I am going to generate a proxy for this service by running the following command from Microsoft.NET/v4 directory on your local machine:
DataSvcutil.exe /uri:http://api.visitmix.com/OData.svc /DataServiceCollection /Version:2.0 /out:VisitMixClientTypes.cs
DataSvcuil is the .NET utility that generates proxies for ADO.NET Data Services or OData.
Once this is done, copy generated file (VisitMixClientTypes.cs) into the project folder and include it in the project. What we have inside the file is the proxy for OData service.
Nest step is to update the XAML to match our proxy. In my simple example I will use the list of sessions and show it on the front page. Here is what my XAML looks like for my main page (MainPage.xaml)
<!--ContentGrid contains ListBox. Place additional content here--><Grid x:Name="ContentGrid" Grid.Row="1"><Grid.Projection><PlaneProjection/></Grid.Projection><ListBox x:Name="ListBoxOne" MouseLeftButtonUp="ListBoxOne_MouseLeftButtonUp"Style="{StaticResource PhoneListBox}"><ListBox.ItemTemplate><DataTemplate><StackPanel x:Name="DataTemplateStackPanel" Orientation="Horizontal"><Border x:Name="DataTemplateBorder" Height="44" Width="44" BorderBrush="White"BorderThickness="2.5" CornerRadius="100" Margin="10,16,0,0"VerticalAlignment="Top"><Path x:Name="DataTemplatePath" Height="16" Width="11" Fill="White"Stretch="Fill" Margin="4,0,0,0" HorizontalAlignment="Center"VerticalAlignment="Center" UseLayoutRounding="False"Data="M337.59924,129.61948 L337.59924,141.51501 L345.5704,135.87381 z"/></Border><mpc:ListViewItem Layout="TextAndDetailsWithIcon" Text="{Binding Title}"Details="{Binding Body}" Style="{StaticResource PhoneListBoxItemLayout}"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></Grid>
I am only copying the main portion of UI, not entire page here.
I am also going to update the details page that is generated by the project wizard to match my data as well. Here is what it looks like:
<Grid x:Name="LayoutRoot"Background="{StaticResource PhoneBackgroundBrush}"d:DataContext="{Binding Items[0]}"><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/></Grid.RowDefinitions><!--TitleGrid is the name of the application and page title--><Grid x:Name="TitleGrid" Grid.Row="0"><Grid.Projection><PlaneProjection/></Grid.Projection><TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextPageTitle2Style}"/></Grid><!--ContentGrid contains the details--><Grid x:Name="ContentGrid" Grid.Row="1"><Grid.Projection><PlaneProjection/></Grid.Projection><TextBlock TextWrapping="Wrap" Text="{Binding Body}"Style="{StaticResource PhoneTextBodyTextStyle}"/></Grid></Grid>
Now, let’s work on code behind to call our OData service. Here is entire code behind for MainPage.xaml.cs:
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using Microsoft.Phone.Controls;using System.Windows.Navigation;using EventModel;using System.Collections.ObjectModel;using System.Data.Services.Client;using System.Windows.Input;namespace WindowsPhoneListApplication1{public partial class MainPage : PhoneApplicationPage{object _selectedItem;EventEntities _entities = new EventEntities(new Uri("http://api.visitmix.com/OData.svc/"));public MainPage(){InitializeComponent();SupportedOrientations = SupportedPageOrientation.Portrait;Loaded += new RoutedEventHandler(MainPage_Loaded);PageTransitionList.Completed += new EventHandler(PageTransitionList_Completed);var query = _entities.CreateQuery<Session>("Sessions");query.BeginExecute(ar =>{DataLoaded(ar);}, query);}private void DataLoaded(IAsyncResult result){try{DataServiceQuery<Session> query = result.AsyncState as DataServiceQuery<Session>;List<Session> sessions = query.EndExecute(result).ToList();Dispatcher.BeginInvoke(() =>{this.ListBoxOne.ItemsSource = sessions;});}catch (Exception ex){Exception thing = ex;}}private void MainPage_Loaded(object sender, RoutedEventArgs e){// Reset page transitionResetPageTransitionList.Begin();}private void ListBoxOne_MouseLeftButtonUp(object sender, MouseButtonEventArgs e){// Capture selected item data_selectedItem = (sender as ListBox).SelectedItem;// Start page transition animationPageTransitionList.Begin();}private void PageTransitionList_Completed(object sender, EventArgs e){// Set datacontext of details page to selected listbox itemNavigationService.Navigate(new Uri("/DetailsPage.xaml", UriKind.Relative));FrameworkElement root = Application.Current.RootVisual as FrameworkElement;root.DataContext = _selectedItem;}}}
The code above is fairly easy. First, I create a DataSericeQuery of type Session. Session type is part of our generated proxy. It then call BeginExecute and pass it a handler. Inside the handler (DataLoaded) I fire EndExecute, then set the items source for my ListBox. I have to make sure to use Dispatcher for this call, otherwise I will get cross thread access exception because handler is not firing on UI thread.
That is it. You can now run the application and see the list of sessions at the MIX 2010. You can also click on an item to see the details.
Please post your questions here.
Thanks.
In this post I will go through the steps of creating my first Windows Phone 7 application using Silverlight. It will be simple and will mostly concentrate on tools rather than phone specific functionality. Of course, I will do more posts describing features that are specific to Silverlight for Windows Phone 7.
First thing I have to do is download the tools and install them on my machine. You can find all appropriate link on www.Silverlight.net. If you click on Getting Started menu, you can look for phone development tools. You will download and install Visual Studio 2010 Express for Windows Phone. Once you are done with that task, start the studio.
Here is what the screen look like.
Let’s go ahead and click on New Project link. Let’s select Silverlight tree node, then Windows Phone application. One side note – no VB.NET menu inside Studio for Phone.
Once project is created, you will see the screen that contains three parts by default – solution explorer, XAML view and Design view.
Now we can even run the application. Let’s go ahead and do this. What we will see is the Phone emulator as well as studio going to debug mode. it will take a few minutes first time you run as emulator initializes. You can resize the emulator by clicking on the menu that I have pointed to with a hand cursor on the picture below. Eventually application loads, and you will the application just created, more precisely title and subtitle blocks.
Let’s add a few controls and some code now. You will notice that when you stop debugging the studio that emulator keeps running. This is good, and you want to keep it running in order to save deployment and initialization time.
We will use the studio’s designer surface to add controls to the surface. To do so, activate toolbox and pin it.
Let’s drag and drop a button onto design surface. Here is what we will see now.
Let’s now add event handler for click event. To do so, double-click on the button on design surface. Code view will open and handler will be created. We will do something really simple, we will change the title as follows:
private void button1_Click(object sender, RoutedEventArgs e){this.textBlockPageTitle.Text = "I changed the title";}
Let’s run the application and see our code in action by clicking on the button. Now, the step we are going to do is explore debugging. To do so, set a breakpoint inside the event handler.
Run the application again from studio by clicking on debug button inside the studio. I put hand cursor next the button.
Once the emulator loads the application, click on the new button inside the application we added. Voila! Our break point got hit.
I illustrated in this post how to create a sample application inside Express Studio for Windows Phone, add controls to the design surface, write code behind and set breakpoints.
One last note. You will notice that even new controls dropped onto design surface are styled certain ways to match overall phone design. If you wonder why, it is because new project wizard comes preloaded with default styles for all basic controls. To look at those styles, just open app.xaml. For example, you can search for TargetType="ButtonBase" to see style for button.
There will be more to come as I explore phone specific features in Silverlight for Windows phone.
Thanks.
I submitted sessions to this year’s CodeStock event. You can vote now for all sessions here.
If you would like to see my session, please vote for them. Here is my list
Thank you and I hope to see you there.
Last week I took a stab at creating my first PowerPivot spreadsheet, and I wanted to document the steps. Maybe this post will help someone, but it will help me remember, that is for sure!
Before you get started, you will need to download all the software required. Here is my list:
Of course, you will need and instance of SQL Server 2008. You can just use Express edition if you do not have one installed.
Now that I have everything installed and configured, I can start with PowerPivot. One note – look for Hand shaped cursor in the screens below.s
Step 1 – Start up Excel 2010 and look for PowerPivot menu, then click on PowerPivot Window to launch pivot.
Step 2 – click on From Database in the window, then Select from SQL Server
Step 3 – Fill in SQL Server details. I am choosing to use Data Warehouse DB. Click Next when done. On the next screen select an option to Select for a list of tables and views.
Step 4 – Select dimension tables and fact table to analyze. Here is my list in alphabetical order
You can select any tables you like of course. Wait while data is imported into PowerPivot, then click Close. PowerPivot window will now have five tabs with data and columns directly imported from the database. Here is what it looks like.
Now click on PivotTable menu and select Chart and Table – Vertical option. We will simply create a chart and an analysis table to go with it. Click on New Worksheet when prompted. This step will return you back to main Excel window. You will see chart, table and on the left hand side Gemini task pane – listing of imported data. Gemini used to be Microsoft code name for this product/functionality.
Step 5 – Building a chart. We are going to analyze sales based on customer marital status by linking it to sales amount. Click on the chart first, then in Gemini pane expand DimCustomer table and select MaritalStatus. Then, expand FactInternetSales and select SalesAmount. PowerPivot will guess what we are trying to do and MaritalStatus as Axis field and Sum(SalesAmount) as Values. Here is what it looks like:
Step 6 – building table with filters.
Click on table first, then check the following tables/fields in Gemini pane:
At this point your bottom of Gemini pane should look like this:
if you have anything else in Values, click on that item and select “Move to Row labels”. What you will see also is that your have a report built for you in table area that uses all the analysis points. You could leave it as is, but I will do more.
Step 7 Now I can analyze the data by “slicing it”. To do this we will create two groups of slices – horizontal and vertical. We will split our analysis categories as follows:
I will leave Sales Territory country as a column in my table. To perform this I will click on each of my slices and select “Move to Slices Horizontal (or Vertical) as appropriate. Then I click on each slice and choose Move Up or down until my pane looks like this:
Now here is what my table looks:
I will go ahead and move things around to make spreadsheet look better:
Step 8 – Use slices for analysis. This process is super simple – just click on a desired slice(s) to enact filter on rows of a table.
To clear the filter just click on a funnel picture with x across it:
As you do so, you will see the chart and table both updating with your filter values. One thing I did notice at the end – Catergory is lon linked to internet sales, so category filter has no effect on data. If you see similar behavior, your data has the same issue. You can always manually build relationships in PowerPivot by click on Table tab in pivot and choosing Manage Relationships menu:
As you can see, using PowerPivot is extremely easy and the results are very powerful. You can save your spreadsheet, open it later and refresh the data by clicking on a filter! You also have an option to show or hide Gemini panels in Excel under PowerPivot menu. In the same menu you also have an option to show or hide Gemini panels.
Thanks.
Today I was faced with an issue. I had an interface based implementation of a specific functionality. All classes that implemented this interface had different implementation of course. What I had to add is ability to run certain checks on each implementation that would need to analyze the data defined in the interface and return a Boolean result of this check.
The problem was that the checks were all the same and I hated to add this check to the interface and write identical code in all implementations. As everyone knows interfaces cannot contain implementation code though. So, what should I do?
So, a particular .NET 3.5 feature came to my rescue. I am referring to extension methods. As you may or may not know extension methods are tied to a type. Well, interface is a type too. Here is some code to look at.
Here is the interface definition:
public interface ISupportCustomAction
{
Action CustomAction { get; set; }
void Execute();
}
Here is my class definition that implements this interface
public class CustomActionOne : ISupportCustomAction
{
#region ISupportCustomAction Members
private Action action;
public Action CustomAction
{
get
{
return action;
}
set
{
action = value;
}
}
public void Execute()
{
// fill in the method
}
#endregion
}
Finally, here is my extension method
public static class ISupportCustomActionExtensions
{
public static bool Check(this ISupportCustomAction action)
{
if (action.CustomAction == null)
{
return false;
}
else
{
return true;
}
}
}
Here is my test code to confirm that everything works
class Program
{
static void Main(string[] args)
{
CustomActionOne action = new CustomActionOne();
action.CustomAction = () => { Debug.WriteLine("Exectuted Action."); };
Analize(action);
action = new CustomActionOne();
Analize(action);
Console.ReadKey();
}
private static void Analize(ISupportCustomAction action)
{
if (action.Check())
{
Console.WriteLine("Can execute action");
}
else
{
Console.WriteLine("Cannot execute action");
}
}
}
How useful this is? Pretty useful in my case. Saved me some typing and resulted in consistent coding. My point is that is good to know what features .NET has and use them as a need arises. As you can see I have a hybrid here of a base (abstract) class and an interface. As a result, I am able to use features that belong to both concepts.
What does this code remind you of? Can you say “Multiple Inheritance in C#?” Well, not exactly, but pretty close.
Thanks.