David

  • About Me
  • GoGetter for Windows Phone 7
  • My Etsy Shop
  • Random
  • Archive
  • RSS
  • Ask me anything
Well, I started working on a Windows Phone 7 Series app. Here is a little preview of the earlier stages of my app when I first started. I will be posting more soon. 
Pop-upView Separately

Well, I started working on a Windows Phone 7 Series app. Here is a little preview of the earlier stages of my app when I first started. I will be posting more soon. 

    • #WP7
    • #silverlight
  • 1 year ago
  • Comments
  • Permalink
  • Share

Installing Windows Phone Developer Tools CTP April Refresh

Just a little advice when installing to the latest version of the Windows Phone Developer Tools (Version 1.0 Release Date 4/29/2010) make sure that you first have uninstalled Visual Studio 2010 RC and have installed the RTM version. After you have done that make sure you have, as well, uninstalled the previous version of Windows Phone Developer Tools CTP. Here is a screenshot of requirements that need to be met before you can install to the current version of Windows Phone Developer Tools. Might save you some time figuring it out.

Happy coding!

    • #WP7
    • #silverlight
  • 1 year ago
  • 5
  • Comments
  • Permalink
  • Share

Configuring your Windows Phone Application after updating to Windows Phone Developer Tools CTP April Refresh update

Well, this is another small piece of advice, something I ran into when I was about to start working on my Windows Phone application after I performed an update to the Windows Phone Developer Tools CTP April Refresh. When I opened my project I was prompted to update my WMAppManifest.xml file with the following:

      <Capability Name=”ID_CAP_NETWORKING” />
      <Capability Name=”ID_CAP_LOCATION” />
      <Capability Name=”ID_CAP_SENSORS” />
      <Capability Name=”ID_CAP_MICROPHONE” />
      <Capability Name=”ID_CAP_MEDIALIB” />
      <Capability Name=”ID_CAP_GAMERSERVICES” />
      <Capability Name=”ID_CAP_PHONEDIALER” />
      <Capability Name=”ID_CAP_PUSH_NOTIFICATION” />
      <Capability Name=”ID_CAP_WEBBROWSERCOMPONENT” />

This was pretty simple to update. This is what my WMappManifest.xml file looked like after I did the update.

Not too shabby thus far. When I compiled my application the only thing that stopped me was having the Visible property enabled to true on the shell:ApplicationBar tag.

Just remove this property and you should be up and running smoothly after performing the Windows Phone Developer Tools CTP April Refresh update. Hope this helps.

    • #WP7
    • #silverlight
  • 1 year ago
  • Comments
  • Permalink
  • Share

Signed Assemblies Bug in the Windows Phone Tools CTP Refresh

I ran into this problem after I updated to the Windows Phone 7 Tools CTP April Refresh. Hopes this helps you out as well.

    • #WP7
    • #silverlight
  • 1 year ago
  • Comments
  • Permalink
  • Share
Boring code for boring work. zzzzzzzzz Can I work on something more interesting please?!
Pop-upView Separately

Boring code for boring work. zzzzzzzzz Can I work on something more interesting please?!

    • #work
    • #code
    • #silverlight
    • #programming
    • #boring
    • #c
    • #.net
    • #linq
    • #linq to objects
    • #mvvm
  • 2 months ago
  • Comments
  • Permalink
  • Share
Working on a basic staff listing page using Silverlight and MVVM. Overkill? Maybe so. This is the before page. Will post the after page and link soon. Stay tuned.
Pop-upView Separately

Working on a basic staff listing page using Silverlight and MVVM. Overkill? Maybe so. This is the before page. Will post the after page and link soon. Stay tuned.

    • #c
    • #silverlight
    • #mvvm
    • #asp.net
    • #.net
    • #programming
    • #developer
  • 2 months ago
  • Comments
  • Permalink
  • Share

Basic staff listing page done in Silverlight and MVVM

I created a basic listing page for my job that dealt with listing our current faculty fellows and mentors where I work at. The process was not too bad. I could have done it using basic HTML5 and CSS, however, my passion is Silverlight, MVVM, and the .Net stack. Being able to use C# and XAML is a blessing. So, I went with this route.

For starters I created your typical Silverlight solution in Visual Studio. In my case, I did not include the ASP.Net web project. All I needed was the xap, in which I will just pop into a basic HTML page.

Next, I included the MVVM Light toolkit into my project. I ended using NuGet to include this into my project.

Once, I had everything installed. I then proceeded creating the Model of the items I needed. In this case I just needed a list of people. I created a class named Person.cs from there I shaped the model.

Once the Model of Person was completed. I then proceeded working on the ViewModel of the application. When you install MVVM Light toolkit and create a project based off it, it creates a simple project layout. You will see a folder named ViewModel and within it you will see two starter ViewModels (MainViewModel.cs and ViewModelLocator.cs)

The ViewModelLocator.cs is where all of your ViewModels are register for the MVVM Light toolkit framework. Once, they are registered this allows our Views to bind to our ViewModels using {Binding ViewModel} in the XAML of our Views. In this file you will see MainViewModel registered there.

As for our MainViewModel it truly is simple. All we really need are some list to distinguish between Faculty Fellows and Faculty Mentors. What I did was create three list of type Person (from our Person.cs class).

List<Person> People { get; set; } will contain everyone regardless of a fellow or mentor.

List<Person> Fellows { get; set; } will contain people who are fellow members.

List<Person> Mentors { get: set; } will contain people who are mentors.

These are declared as public properties within our MainViewModel. Next thing to do is to filter List<Person> People to either a Fellow or Mentor. This is done in the constructor of our class. But let me show you what the initialization of our People list looks like first.

I create People list through object initialization a feature in C#. Within this you will notice our shape of our Model. There are two key properties to notice in this model the IsFellow and IsMentor properties. Yes, there are other ways to filter, but this was quick and easy for me. Lets look at the MainViewModel now.

Within the MainViewModel after I initialized the People, Fellows, and Mentors list I then filter the People list into either the Fellows or Mentors list with a simple foreach call.

foreach (var _person in People)
{
                    if (_person.IsFellow == true)
                    {
                        Fellows.Add(_person);
                    }
                    if (_person.IsMentor == true)
                    {
                        Mentors.Add(_person);
                    }
}

After this is done we have everyone in their appropriate list. Now we need to design the UI of our app.

What I was looking for was something pretty simple to display the data. At the top of the Silverlight app I wanted a big splash image, along with it changing to a Faculty Fellow or Mentor whenever the user selected a particular list item. In the blue frame is the splash/fellow/mentor image, in the red frame are the fellows, and in the green frame are the mentors.

The blue frame is basically a image denoted as: <Image x:Name=”imgPerson” Stretch=”Fill” Source=”Photos/group.png” Width=”700”/>

The source of the image will be updated whenever a fellow or mentor are selected by the two list below.

The markup of the list are as of:

<ListBox x:Name=”lstFellows” Width=”335” Height=”465” Margin=”10,10,5,10” ItemTemplate=”{StaticResource dtPeople}” ItemsSource=”{Binding Fellows}” SelectionChanged=”lstFellows_SelectionChanged” BorderThickness=”0”/>


<ListBox x:Name=”lstMentors” Width=”335” Height=”465” Margin=”5,10,10,10” ItemTemplate=”{StaticResource dtPeople}” ItemsSource=”{Binding Mentors}” SelectionChanged=”lstMentors_SelectionChanged” BorderThickness=”0” MinWidth=”1”/>

What makes this works with binding to the MainViewModel is that each list’s ItemSource is bounded to the MainViewModels public list properties:

public List<Person> Fellows { get; set; }
public List<Person> Mentors { get; set; }

How did we glue the View and the ViewModel together to make this happen? Well, in the XAML of our View we assigned its DataContext as shown:

The design view in Expression Blend looks like this.

Now we have to design the list box items of the list. They are bounded to the MainViewModel’s lists of Person, but we need to tell the View’s lists how to display that data. To do that you will need to right click the list then go to Edit Additional Templates->Edit Generated Items->Edit a Copy

Once we do that, we can then edit the ItemTemplate for the list. Modifications here will apply to all of its list items. You can apply this template to the lstMentors too. So, modify once and use it on any other list as you see fit.

Now that we are in the right place to modify the items of the list we then need to create text blocks and an image to show show our fellow or mentor and their associated data (name, college, department, etc..) As you see, above I have already created the basic structure for each list item. How do we now assign those text blocks and image to each list item? Well, you need to select the text block or image and assign its Text or Source property to the Person model’s respective property. For the txtName text block will assign its Text property to the Person’s Name property as follows:

You will perform this technique for each text block and its associated Person’s model property, even for the image’s Source property to the Person’s model Photo property (for these thumbnails we used Photo72x72 property of the Person model).

For the most part that is it. However one thing we need to do is to change the main splash image whenever a list item is selected (the blue frame). So, we look into the code behind to handle those selection change events of the lists. I will just show the code since this post is super long as is. Its not too complicated.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace ServiceLearningFacultyFellows
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            // Required to initialize variables
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            imgPerson.Source = new BitmapImage(new Uri(“Photos/group.png”, UriKind.Relative));
        }

        private void lstFellows_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            Person _person = lstFellows.SelectedItem as Person;
            if (_person != null)
            {
                imgPerson.Source = _person.Photo;
                #region IniBio
                txtBio.FontSize = 15.333;
                txtBio.Text = _person.Bio;
                #endregion
                #region IniBorder
                brdBio.Width = 420.00;
                Canvas.SetLeft(brdBio, 272);
                Canvas.SetTop(brdBio, 8);
                #endregion
                brdBio.Visibility = Visibility.Visible;
            }
                lstMentors.SelectedIndex = -1;
        }

        private void lstMentors_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            Person _person = lstMentors.SelectedItem as Person;
            if (_person != null)
            {
                imgPerson.Source = _person.Photo;
                #region IniBio
                if (string.Equals(_person.Name, “Dr. Katie Langford”))
                {
                    txtBio.FontSize = 13.133;
                }
                else
                {
                    txtBio.FontSize = 15.333;
                }
                txtBio.Text = _person.Bio;
                #endregion
                if (string.Equals(_person.Name, “Dr. Jacki Fitzpatrick”))
                {
                    #region IniBorder
                    brdBio.Width = 600.00;
                    Canvas.SetLeft(brdBio, 50);
                    Canvas.SetTop(brdBio, 67);
                    #endregion
                }
                else
                {
                    #region IniBorder
                    brdBio.Width = 420.00;
                    Canvas.SetLeft(brdBio, 272);
                    Canvas.SetTop(brdBio, 8);
                    #endregion
                }
                brdBio.Visibility = Visibility.Visible;
            }
            lstFellows.SelectedIndex = -1;
        }
    }
}

You will notice that I modify the background and text size when certain people are select in the list. This is because their bio’s are just to damn long. So, I had to adjust the text size in some cases. And for the shifting of the border (Black boarder that encapsulates the bio of each person) this was done because one faculty member did not have a photo available. So to fill the empty space of no photo I moved the border that held the bio to the center of the splash image.

And below is our final result. I know I might have missed parts in this post, but this was supposed to serve as a overview on how I did it. If you have questions please ask away. I can help you better understand what I did. I had to encapsulate the Silverlight control in an iframe for Tumblr. So, you will see part of it cut off to the right for the sake of fitting correctly in my theme’s content width. To see the app in all its glory click this link:

    • #mvvm
    • #silverlight
    • #csharp
    • #asp.net
    • #how-to
    • #mvvm light toolkit
    • #developer
    • #wp7
    • #wp7dev
    • #.net
    • #programming
    • #visual studio
    • #expression blend
    • #GoGetter
  • 2 months ago
  • Comments
  • Permalink
  • Share

Exiting a Windows Phone Application Programatically

This is just a helpful tip for those who do Windows Phone development. I had issues on trying to figure out what the best way was to exit my app from the app’s main root page. For a while I just threw an exception such as this:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

        {

            base.OnBackKeyPress(e);

            throw new Exception(“Exit Main”);           

        }

It irked me to do this, but it worked and passed Marketplace certification. Well, I was needing to perform some code on the App.xaml.cs level when exiting my app:

private void Application_Closing(object sender, ClosingEventArgs e)

        {

            // Do stuff here

        }

Well, this code was never called due to the exception being thrown from my main page when the back button was pressed. So, I dug in a bit to the NavigationService class and realized I could actually remove all back entries that were on the back stack. Joy! So, this is what I came up with for the OnBackKeyPress event:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

        {

            base.OnBackKeyPress(e);

            if (NavigationService.CanGoBack)

                {

                    while (NavigationService.RemoveBackEntry() != null)

                    {

                        NavigationService.RemoveBackEntry();

                    }

                }          

        }

And voila! It worked. The app exited properly and the Application_Closing event was called from App.xaml.cs which allowed me to do some background processing of my app’s data.

Hope this can help any of you.

    • #c
    • #windowsphone
    • #windows phone
    • #Windows Phone 7
    • #silverlight
  • 1 week ago
  • Comments
  • Permalink
  • Share

Logo

Portrait/Logo

I created an awesome "Getting Things Done" app and I make awesome art.

GoGetter for Windows Phone 7: www.gogetterapp.com
Etsy Shop: davidrodriguez.etsy.com

Me, Elsewhere

  • @davidrodriguez on Twitter
  • Facebook Profile
  • davidarodriguez on Flickr
  • iimmerse on Last.fm
  • My Skype Info
  • Linkedin Profile

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

© 2011 David A. Rodriguez. Effector Theme by Carlo Franco.

Powered by Tumblr