Learning PRISM – Getting Started…

Now that we have covered Unity and Modularity, we can start cutting into the meat of PRISM! 2 more fundamental concepts do need a little explaining… I will cover them as I get to them.

One of the big changes in PRISM is the way the application gets loaded and how it shows the main window. PRISM rely on a Bootstrapper (Or more specifically, the UnityBootstrapper) to create the Shell and ModuleEnumerator 

The shell is the main window. Lets build our “Hallo World”

  1. Create a new WPF Application
  2. Reference the following assemblies (The PRISM stuff)
    1. Microsoft.Practices.Composite
    2. Microsoft.Practices.Composite.UnityExtensions
    3. Microsoft.Practices.Composite.Wpf
  3. Remove the StartupUri from the App.xaml
  4. Remove Window1 and add a new Window called Shell (You could also have renamed the Window1 to Shell)
  5. Add a new class called Bootstrapper

By default, we will derive from the UnityBootstrapper. For now, all your bootstrapper will do is create our shell and allow for static enumeration of our modules. Here is my bootstrapper

public class Bootstrapper : UnityBootstrapper
{
    protected override System.Windows.DependencyObject CreateShell()
    {
        Shell shell = new Shell();
        shell.Show();
        return shell;
    }
    protected override Microsoft.Practices.Composite.Modularity.IModuleEnumerator GetModuleEnumerator()
    {
        return new StaticModuleEnumerator();
    }
}
The last step is to instantiate the bootstrapper… To do this, we override the OnStartup of App.
protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);
    Bootstrapper bootstrapper = new Bootstrapper();
    bootstrapper.Run();
}

Now we have a very basic PRISM application… I highly recommend you do this by hand the first 2 or 3 times just to grasp why you have all these things… but if you are lazy (like me), use the Visual Studio Project Template available on Composite WPF Contrib

Read more here

Posted by rudi | 4 comment(s)

Validation in WPF using PostSharp/AOP

Last night I went to a excellent SADeveloper.net event about AOP with PostSharp and it had me thinking…

Granted, validation is probably not the text book example of cross cutting concerns but it does proof how PostSharp/AOP can be used…

What is AOP?

Aspect-oriented programming (AOP) is a programming paradigm that increases modularity by allowing the separation of cross-cutting concerns.

Lets assume that I want to validate the age of my employees, I could do the following in my business entity

int age;
public int Age
{
    get { return age; }
    set
    {
        if (value < 18)
            throw new Exception("Value must be between 18 and 99");
        if (value > 99)
            throw new Exception("Value must be between 18 and 99");

        age = value;
    }
}
Now I can “turn on” ValidateOnExceptions in my UI
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=Age, Mode=TwoWay, 
    UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, 
    ValidatesOnExceptions=True}" Width="50" HorizontalAlignment="Left" VerticalAlignment="Top" />

This works, but what if I want to reuse this logic to check that the compulsory HR test written by each employees score is legal (ie. between 5-25)? How can I change this code to be more reusable? Enter the world of PostSharp and AOP

I created a pretty simple attribute using PostSharp

[Serializable]
public class RangeValidator : OnMethodBoundaryAspect
{
    public int Min { get; set; }
    public int Max { get; set; }

    public RangeValidator(int min, int max)
    {
        Min = min;
        Max = max;
    }

    public override void OnEntry(MethodExecutionEventArgs eventArgs)
    {
        if (!eventArgs.Method.Name.StartsWith("set_"))
            return;

        var args = eventArgs.GetReadOnlyArgumentArray();
        if (args.Count() == 0)
            throw new Exception("No argument passed to set");

        int value = (int)args[0];
        if (value > Max)
            throw new Exception("Value must be between " + Min + " and " + Max);
        if (value < Min)
            throw new Exception("Value must be between " + Min + " and " + Max);

        base.OnEntry(eventArgs);
    }
}

This is a simple example of how to use PostSharp… Ok, but how do I now use this attribute? Simple, here is my new business entity

public class Employee
{
    [NotNullValidator]
    [StringLengthValidator(0, 32)]
    public string Name { get; set; }

    [NotNullValidator]
    [StringLengthValidator(0, 32)]
    public string Surname { get; set; }

    [RangeValidator(18, 99)]
    public int Age { get; set; }

    [RangeValidator(5, 25)]
    public int HRTestScore { get; set; }
}

I also “created” a NotNullValidator and StringLengthValidator… This cleans up the code tremendously and it is soooo simple to use!!!

Here is my test UI

Validation is a very easy example but the possibilities doesn’t end their… You can now also create a attribute to automatically implement all the INotifyPropertyChanged stuff…

Pete Weissbrod has a excellent 2 part post about how he did exactly that (Part 1 and Part 2)

PS. The form was created using XAML Power Toys... I highly recomend you check it out, read more here!

kick it on DotNetKicks.com
Posted by rudi | 7 comment(s)

Binding to enum’s

 

Maximilian asked the following question on Stack Overflow: Databinding an enum property to a ComboBox in WPF?

Let’s create a very simple example

public enum EmployeeType    
{
    Manager,
    Worker
}

Each employee can either be a Manager or a Worker… Here is my Employee “model”

public class Employee : BindableObject
{
    private string name;
    public string Name 
    {
        get { return name; }
        set 
        { 
            name = value;
            RaisePropertyChanged("Name");
        }
    }

    private string surname;       
    public string Surname 
    {
        get { return surname; }
        set
        {
            surname = value;
            RaisePropertyChanged("Surname");
        }
    }

    private EmployeeType type = EmployeeType.Worker;
    public EmployeeType Type 
    {
        get { return type; }
        set 
        { 
            type = value;
            RaisePropertyChanged("Type");
        } 
    }
};

I then create a ObservableCollection<> of dummy data and set my DataContext

DataContext = new ObservableCollection<Employee>() {
    new Employee() { Name = "Butch", Surname = "James", Type = EmployeeType.Worker },
    new Employee() { Name = "John", Surname = "Smith", Type = EmployeeType.Manager },
    new Employee() { Name = "Brian", Surname = "Mujati", Type = EmployeeType.Worker },
    new Employee() { Name = "Tendai", Surname = "Mtawarira", Type = EmployeeType.Worker },
    new Employee() { Name = "BJ", Surname = "Botha", Type = EmployeeType.Worker },  
    new Employee() { Name = "Juan", Surname = "Smit", Type = EmployeeType.Worker }};
Now we are ready to try and create some basic UI for this application!

To bind to the enum, we have 2 choices… we can set the ComboBox’s ItemsSource in the code behind

typeComboBox.ItemsSource = Enum.GetValues(typeof(EmployeeType));

Or we can try and do it the WPF way using only XAML?

<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="sysEnum">
    <ObjectDataProvider.MethodParameters>
        <x:Type TypeName="local:EmployeeType" />
    </ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

Now we have a StaticResource we can bind to… Here is the ComboBox binding

<ComboBox ItemsSource="{Binding Source={StaticResource sysEnum}}" />

I love WPF… Next, lets bind to our dummy data! I created a simple master/detail form

<ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Margin="0,0,0,10">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Name}" Margin="0,0,5,0" />
                    <TextBlock Text="{Binding Surname}" />
                </StackPanel>
                <TextBlock Text="{Binding Type}" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Here is my master… it is just a ListBox with all the Employees listed!

<StackPanel Grid.Column="1">
    <StackPanel Orientation="Horizontal">
        <Label Content="Name: " />
        <TextBox Text="{Binding Name}" />
    </StackPanel>
    <StackPanel Orientation="Horizontal">
        <Label Content="Surname: " />
        <TextBox Text="{Binding Surname}" />
    </StackPanel>
    <StackPanel Orientation="Horizontal">
        <Label Content="Type: " />
        <ComboBox ItemsSource="{Binding Source={StaticResource sysEnum}}" SelectedValue="{Binding Type}"/>
    </StackPanel>
</StackPanel>

And finally our details pane where you can change the employee’s name, surname and type!

That is it, if you found this useful, please kick it on DotNetKicks.com

Posted by rudi | 3 comment(s)
Filed under: , ,

Learning PRISM – Modularity

Background

Modularity is not a new concept! Here is the official Microsoft definition:

Modularity is designing a system that is divided into a set of functional units (named modules) that can be composed into a larger application. A module represents a set of related concerns. It can include components, such as views or business logic, and pieces of infrastructure, such as services for logging or authenticating users. Modules are independent of one another but can communicate with each other in a loosely coupled fashion.

If you have used WPF for a while you may think that this is a little redundant… You can divide your UI into UserControls and then compose them at runtime, so what advantage does PRISM give us here? Good question, let’s start with the basics and work our way up…

public classSimpleModule : IModule
{
    private readonly IRegionManager _regionManager;

    publicSimpleModule(IRegionManager regionManager)
    {
        _regionManager = regionManager;
    }

    public voidInitialize()
    {
        // Do something here...
  
}
}

This is the simplest module you can possible create. To qualify as a Module, you have to implement the IModule interface. The IModule interface defines 1 method: void Initialize()

[NOTE] Interfaces == Loose coupling!

When a module is initialized, it can register views and services or inject a view into a Shell region.

public voidInitialize()
{
    _regionManager.Regions["MainRegion"].Add(newSimpleView());
}

This code finds a region in my shell called MainRegion and injects my view (UserControl) into it. This is a great pattern to use but currently it has no advantage over just using UserControl! What else can this baby do?

The big advantage in using PRISM here is how the modules are located (discovered) and loaded

  • Static Module Loading
  • Dynamic Module Loading
    • Directory Driven Module Loading
protected override IModuleEnumerator GetModuleEnumerator()
{
    return new DirectoryLookupModuleEnumerator(@".\Modules");
}
    • Configuration Driven Module Loading
protected override IModuleEnumerator GetModuleEnumerator()
{
    ConfigurationStore store = new ConfigurationStore();
    return new ConfigurationModuleEnumerator(store);
}
    • On-Demand Module Loading

The static module loading is similar to how you would do it only using UserControls but the real power is in the dynamic loading of modules. Currently there are 3 dynamic methods supported: Find all the modules in a directory, load from configuration file or load modules on demand!

If you found this article useful, please kick it on DotNetKicks.com

Read more

WPF Questions on Stack Overflow

If you don’t know what Stack Overflow is, check out this diagram…

Stack Overflow is that tiny asterisk in the middle! Here is some of the cool WPF related questions already asked:

If you have any programming related question… try out Stack Overflow

What is Stack Overflow?

Joel Spolsky

Every question in Stack Overflow is like the Wikipedia article for some extremely narrow, specific programming question. How do I enlarge a fizzbar without overwriting the user’s snibbit? This question should only appear once in the site. Duplicates should be cleaned up quickly and redirected to the original question.

Some people propose answers. Others vote on those answers. If you see the right answer, vote it up. If an answer is obviously wrong (or inferior in some way), you vote it down. Very quickly, the best answers bubble to the top. The person who asked the question in the first place also has the ability to designate one answer as the “accepted” answer, but this isn’t required. The accepted answer floats above all the other answers.

Every question in Stack Overflow is like the Wikipedia article for some extremely narrow, specific programming question. How do I enlarge a fizzbar without overwriting the user’s snibbit? This question should only appear once in the site. Duplicates should be cleaned up quickly and redirected to the original question.

Some people propose answers. Others vote on those answers. If you see the right answer, vote it up. If an answer is obviously wrong (or inferior in some way), you vote it down. Very quickly, the best answers bubble to the top. The person who asked the question in the first place also has the ability to designate one answer as the “accepted” answer, but this isn’t required. The accepted answer floats above all the other answers.

Jeff Atwood

From day one, my blog has been about putting helpful information out into the world. I never had any particular aspirations for this blog to become what it is today; I'm humbled and gratified by its amazing success. It has quite literally changed my life. Blogs are fantastic resources, but as much as I might encourage my fellow programmers to blog, not everyone has the time or inclination to start a blog. There's far too much great programming information trapped in forums, buried in online help, or hidden away in books that nobody buys any more. We'd like to unlock all that. Let's create something that makes it easy to participate, and put it online in a form that is trivially easy to find.

Are you familiar with the movie pitch formula?

Stackoverflow is sort of like the anti-experts-exchange (minus the nausea-inducing sleaze and quasi-legal search engine gaming) meets wikipedia meets programming reddit. It is by programmers, for programmers, with the ultimate intent of collectively increasing the sum total of good programming knowledge in the world. No matter what programming language you use, or what operating system you call home. Better programming is our goal.

Learning PRISM – Unity Redux

If you missed the first post in this series, please read it first. I received quite a few emails in response too my first article… I would like to address them here:

What does unity have to do with PRISM?

I have to agree that my first post did not really put unity in context. So lets try again… Their are 2 main areas where Unity help… As I stated in the first post, you can call RegisterType<> on a type… What I did not mention is that you can also call RegisterInstance<>. This allows us to register a instance that can be used. Taking my first example of ILogger, if I only wanted 1 instance of ILogger to be passed to everyone that uses ILogger, I could have changed my code as follows:

container.RegisterInstance<ILogger>(new ConsoleLogger());

Now when I call resolve, I will always get the same instance!

ILogger logger = container.Resolve<ILogger>();

This is a very cool feature of unity (And IoC’s in general)… But how is it used in PRISM?

Regions and RegionManager will only be discussed later… but thy use this feature. For now you can think of a region as a place holder on the screen where I can “inject” a view and the RegionManager is my way of finding the regions!

IRegionManager manager = container.Resolve<IRegionManager>();
IRegion mainRegion = this.regionManager.Regions["MainRegion"];

By just having a reference to the container, I was able to get the RegionManager and from the RegionManager I got a region!

Other shared services that use this is: IContainerFacade, IEventAggregator & IModuleLoader

The next feature that can be used from unity is the fact that unity can be setup/configured from a simple config file!!!

Read more about this feature here

This makes your application even more loosely coupled!

Why do you use PRISM and not Composite Application Guidance?

PRISM just sounds better :)

More information about Unity Application Block & PRISM

http://msdn.microsoft.com/en-us/library/cc468366.aspx

http://www.codeplex.com/unity

http://www.codeplex.com/CompositeWPF

 

Next to be covered is modularity!

Posted by rudi | 5 comment(s)

From Flash to Silverlight…

And the battle continues…

This week sees the birth of project rosetta

What is Project Rosetta?
Project Rosetta is a site dedicated to helping designers and developers build applications in Silverlight while taking advantage of skills they already know.

Rick Barraza (Project maestro fame) published the first article From Flash to Silverlight (9 lessons on how to use your Flash skills in Silverlight). Also check out the Channel 9 interview with Rick

Flash vs Silverlight on Shine Draw! Here are some of the comparisons:

Which do you prefer? Why? Is/will silverlight live up to the hype? Will it be the …killer?

kick it on DotNetKicks.com
Posted by rudi | 1 comment(s)

Learning PRISM – Unity

 

I was recently tasked with learning PRISM… The next few post will document my learning experience! PLEASE NOTE: I have no experience with previous technologies like CAB… This is truly my idiots opinion about what I have learned trying out PRISM!

I have identified some key “things” I MUST know in order to use PRISM (This list might change in the future). As I learn more about each one of these… I will post about it! The first item on my list is Unity!

The Unity Application Block (Unity) is a lightweight extensible dependency injection container with support for constructor, property, and method call injection.

If you want to learn more about dependency injection and IoC, here are some resources that helped me:

IoC and Unity - The Basics and Interception

IMHO… Their are 2 key things that unity provide that I should know. Lets look at the following interface

public interface ILogger
{
    void LogSomething();
}

And lets create a concrete class implementing this interface

public class ConsoleLogger : ILogger
{
    public void LogSomething()
    {
        Console.WriteLine("ConsoleLogger.LogSomething()");
    }
}

This now makes it very simple for me to in the future create a different logger (ie. SqlLogger, TraceLogger, etc) and swap them at my will!

ILogger logger = new ConsoleLogger();

The only problem with the code above is that I am now tightly coupled to the ConsoleLogger… I actually need to reference the namespace in which I created ConsoleLogger!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This is were the IoC/DI stuff helps! Lets create a container

IUnityContainer container = new UnityContainer();

And then I can register types or instances with this container

container.RegisterType<ILogger, ConsoleLogger>();

and now if I ask my container for a ILogger… It will take care of creating the correct concrete class

ILogger logger = container.Resolve<ILogger>();

 

 

 

 

 

 

The code that actually creates the instance of ILogger, doesn’t need any knowledge of the concrete class!!!

It is actually very simple to create a basic IoC container yourself, here are some examples

Understanding IoC Container - sfeldman.NET

Building an IoC container in 15 lines of code

 

 

 

 

 

 

 

Ken Egozi's IOC in 15 lines

OK, that is the first key “thing”… The next “thing” is the dependency injection… Lets build on our first example that has a logger! Now we also have a CustomerRepository that depends on the ILogger

public class CustomerRepository : ICustomerRepository
{
    ILogger _logger;
    public CustomerRepository(ILogger logger)
    {
        _logger = logger;
    }

    public void GetACustomer()
    {
        _logger.LogSomething();
    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

How does unity help us out here? Well, how would this have been done without unit?

ICustomerRepository repository = new CustomerRepository(new ConsoleLogger);

 

Do you see the tightly coupled stuff? Not so good! Assuming we already have a unity container and a logger registered… here is the unity way

ICustomerRepository repository = container.Resolve<CustomerRepository>();

I supply no parameters… The unit container auto-magically resolves it!!!

This only scratches the surfaces of what IoC/DI is capable of… Also remember that Unity is by no means the only one of its kind… here is a cool list of other containers!!!

And that concludes my first baby steps into the world of loosely coupled applications, Inversion of Control, Dependency Injection and much more…

[UPDATE] More Resources

.NET Hitman has a nice article about IoC & Unity

Andrey Shchekin has a nice 2 part post about comparing popular the IoC containers (Part 1 & Part 2)

 

Posted by rudi | 5 comment(s)

XAML Power Toys

[UPDATE] XAML Power Toys 3.0.0 Released - Code Name: Refactored

Karl Shifflett (AKA The Molenator) has released a (another) AWESOME Visual Studio Add-in called the XAML Power Toys. This add-in, among other things, allow you to create data entry screens for business objects in just seconds… If you write any business applications at this stage, this tool will save you huge amount of work and time…

I highly recommend checking this add-in out!!!

WPF in LOB

Not to overflow you with too many TLA (Three Letter Acronyms) but one of the most talked about things in the WPF world is, is it ready for Line-of-Business?

The purpose of this post is not to debate if it is ready, but rather link too 2 videos of WPF applications used in LOB environment!

Lawson Smart Office brings WPF goodness to the enterprise

This is a very detailed video of how the Lawson application works… It is a very slick user interface build using WPF… and it rocks!!!

[UPDATE] Here is another one done by Frog Design (http://windowsclient.net/learn/video.aspx?v=48556)

Billy Hollis on Getting Smart with WPF

Billy Hollis has a EXCELLENT example of real world use of WPF

Do yourself a huge favor and check these 2 videos out… well worth it!!!

PS. If you really have time for more TLA… learn more about CAL, CAG, CAB, MEF, etc…

Here are 2 podcasts that will get you on your way:

Episode 11- Glenn Block on Prism, Unity, and MEF (part 1)

Episode 12- Glenn Block on Prism, Unity, and MEF (part 2)

And as always, if you found it useful, please kick it on DotNetKicks.com

Posted by rudi | 3 comment(s)

RoboHum V2 (Part 2 – The operating system)

 

If you missed part 1, please read it here

Next in our series of upgrading RoboHum from V1 to V2, we decided to change our operating system from Windows XP Embedded to Windows CE.

The only real problem I ran into here was that I first downloaded the board support package (BSP) for the EBOX-2300 (Not realizing that I should have actually downloaded the EBOX-2300SX). Here is the links for the board support package, etc

Windows CE 6

Vortex86SX Windows Embedded CE 6.0 BSP Version B (2008-07-24)

Windows Embedded CE 6.0 step by step guide

Windows CE 5

Vortex86SX Windows CE 5.0 BSP Version D5 (2008-05-06)

Demo images are also available on the www.vortex86sx.com website!

Now that we have a hardware platform running Windows CE, we can start focusing on the software development. The first problem we have is that we have to turn digital IO’s on and off!

Here is a PDF explaining the IO layout of the EBOX-2300SX-JSK

Now that we know which address spaces we need to access, we need direct IO access!!! The following CodeProject article has a nice explanation on how to do direct IO access in managed code…

In old DOS days we had inp() and outp() functions to do direct IO access. I took what I learned from the previous CodeProject article and made a wrapper that allow me to make direct IO calls. I also made my library so that it works in .NET Framework and .NET Compact Framework. Here is a example of how to use it:

int value = RudiGrobler.DirectIO.PortAccess.inp(0x300);
RudiGrobler.DirectIO.PortAccess.outp(0x300, 0xFF);

My library uses SXIO.dll in CE and winio.dll in Win32. In my wrapper I just call the correct P/Invoke based on the current operating system type!

And that is it for part 2, in part 3 we will dig into the actual Robotic Studio 2008…

RoboHum V2 (Part 1 – The hardware)

 

Ok, this is a 3 part series that I had on the back-burner for a while… never had the time to finish it!!! Well, after listening to a DotNetRocks show #364 (Stacy Harris Does Home Automation!) I decided it is time to finish it! For more info about RoboHum V1, read the post here!

The first part of this series will cover the hardware… The new “PC” I selected is the VERY cost-effective EBOX-2300SX-JSK from DM&P.

Here is a comparison between RoboHum V1 & RoboHum V2

  RoboHum V1 RoboHum V2
Hardware Wafer-LX EBOX-2300SX-JSK
OS Windows XP Embedded Windows CE 6
Estimated Cost (Including board, storage, RAM and OS) R3000 ($375) R1200 ($150)
Supplier www.ieiworld.com http://www.compactpc.com.tw/
CPU AMD Geode LX800 MSTI PSX-300 SoC-366MHz

The Wafer-LX is a excellent board but way to over-speced (and priced) for the real hobbyist type user. I selected to rather use the more cost effective EBOX-2300SX-JSK from DM&P. The added benefit of using this board is that it has a 24-bit onboard GPIO (Which we can use to control the motors)

The EBOX-2300SX-JSK is often used in the robotics space (I think it was also the default equipment used in the Imagine cup – embedded). Here is some pictures of other people using the EBOX in robotics

 

Now that we have a hardware platform we can use, in part 2 I will cover the operating system. This is the next huge change between V1 & V2. We now make use of Windows CE!!!

Posted by rudi | 2 comment(s)

Disposing my crap…

[UPDATED] OK, ignore this post and read the IDispose Guidelines. This is a very lengthy post but well worth the read!!!

 

When using unmanaged resources, you have 2 options cleaning up after using the resources:

1. Override the Finalize.

Pro: Finalize() is called by the GC… just implement it and be sure that the GC will call it

Cons: Performance hit

2. Implement IDisposable

Pro: Lightweight and easy to implement

Cons: Developer must remember to call Dispose() (And we are only human)

Why not combine the 2?

public class MyUnmanagedResource : IDisposable
{
    ~MyUnmanagedResource()
    {
        // Cleanup resources
   
}

    public void Dispose()
    {
        // Cleanup resources

       
GC.SuppressFinalize(this);
    }       
}

Now this might seem a little excessive but I have a Dispose() that can be called by the developer to do the cleanup (This will also ensure that the finalize never happen by calling GC.SuppressFinalize(this)) but if he “forgets” to call the Dispose(), the finalize does the cleanup!!

 

 

 

Over-engineered, maybe! But it is SAFE…

Posted by rudi | 4 comment(s)

Slides and demos from Tech-ed

I had a few emails asking for my slides and demos so here goes:

DEV314 - Building Data Driven Applications using Windows Presentation Foundation
Most rich applications present data, often lots of it. To avoid writing lots of code to support the presentation of that data, you should take full advantage of the data binding capabilities of your presentation platform. This session discusses and demonstrates the data binding capabilities of Windows Presentation Foundation (WPF). It explains what data contexts are and how they work with the element hierarchy. It shows you what Bindings are, how to declare them, and what optional capabilities they support. It demonstrates binding to data sets as well as custom objects and collections, and discusses the considerations for implementing those types. The session shows you how to use data templates to define reusable chunks of UI that can be rendered automatically for each item in a data collection. It also discusses the way you can interact with your bound data programmatically to control the presentation of that data and to make changes to it in code.

Slides

Demos

Comments:

The Good

  • Gave me a starting insight into what to expect if I start doing it but nothing concrete to work with yet. But the ideas presented gave a direction to expect. Lunch was a little distracting as well which didn't help.
  • It would have been better if I knew something about the topic. But a good experience still

The Bad

  • Presenter was not engaging and did not seem confident on the topic
  • mostly duplicate content
  • I actually only got the tail end of the presentation, so my eval may not be fair

The WTF?

  • I DID NOT ATTEND THIS SESSION, BUT BOOKED IT IN THE SESSION PICKER! DON'T KNOW HOW TO "UNBOOK". Please disregard ratings!

DEV315 - Five Cool Things to Know and Use for Smart Client Development with Microsoft Visual Studio 2008 and the Microsoft .NET Framework 3.5
While the world has gone overboard with building Web applications and many developers are focusing purely on the server-side, there are still huge opportunities for creating compelling rich client-based applications that play well in the software-plus-services world. With over 50 minutes of demo time, in this session we explore five new enhancements in Visual Studio 2008 and .NET Framework v3.5 for building smart Windows applications. Demonstrations include Windows Presentation Foundation interoperability, ADO.NET Sync Services, Client Application Services, the Managed AddIn Framework, and customizing Office Applications (Visual Studio Tools for the Microsoft Office System v3.0).

Slides

Demos

Comments:

The Good

  • Good one, need more of these, for all tools.
  • Rudi could become a firm favorite in future sessions! Absolutely brilliant presentation enabled by a high level of comfort with his subject matter.

The Bad

  • The presentation was not always providing solution for smart clients! Maybe the title should be FAT Clients! Did not touch on some IsolatedStorage namespaces or one click client updates; things that are very important for Smart Clients. And also cannot say it was an Advanced course; Maybe 'Intermediate'. Thanks
  • Description was not what was presented on.
Posted by rudi | 3 comment(s)

Silverlight 2 + WCF Service Deployment Issue

While deploying a very simple Silverlight application using a Silverlight enabled WCF service, I ran into this little problem:

On my development machine hosting the app using the normal VS host (By running the app using F5) everything works perfectly (Creating a random port number for the app and service)

If I now deploy this app and service to my production machine, the Silverlight app works but it can’t access the WCF service!!!

Things I double checked:

  1. Make sure the Silverlight application runs. If not, add the MIME types
  2. Make sure the service is working

My service is called MISService.svc so to check that it worked, I opened it in IE (http://localhost/MISService.svc)

If both your Silverlight application and service work, it might indicate a cross domain boundaries problem, here is a document how to fix it.

If it still doesn’t work, try the following:

The problem is that in the ServiceReference.ClientConfig file (Created by using VS Add Service Reference), the endpoint is setup with a specific port number (1192 in the following example)

<client>
  <endpoint address="http://localhost:1192/MISViewerWeb/MISService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MISService"
        contract="MISViewer.MISServiceReference.MISService" name="BasicHttpBinding_MISService" />
</client>

 

 

 

Now if I create the client, I get a UnexpectedHttpResponseCode exception. Here is the code that creates the service client

MISServiceClient client = new MISServiceClient()