The mysteries of software development and networking... RSS 2.0



 Friday, January 11, 2008

The other day I was playing around with WPF in Visual Studio 2008 and I stumbled across some strange behaviour. I made a mistake in the XAML of a WFP Window.

<Button Background="LightBlueX" Name="button1" Click="button1_Click">Click here</Button>

As you can see the name of the Background color is not valid. Now as long as you have the Window opened in the designer the errorlist will display an error to inform you about the mistake. However, if you try and compile your project, you'll find that the compiler will succesfully build. Then when you run the application you'll get a runtime error (a XAML parse exception). Thinking this to be an error in the compiler I logged a bug on MSConnect.

I received the following feedback:

Hi Mark

Thanks for your report. The behavior you're reporting is actually by-design - it arises because of a trade off of complexity/performance in the build/compilation process vs surfacing all possible failures at compile time.

Errors in XAML attribute values like the one mentioned in the bug are one of the class of errors that can't be picked up with certainty by the build process without loading the entire context of the WPF application being built - this is too heavy an overhead to impose on the compilation process and would cause a major performance degradation in building.

The expected process is that the user will use the designer (which of necessity loads a lot more of the context) to locate and eliminate errors of this sort. Hence the fact that the errors list shows the error as described in the repro steps.

Thanks for taking the time to submit the issue - I hope you continue to find the designer useful and would welcome any further feedback you have.

Mark Wilson-Thomas
Program Manager
WPF Designer Team, Developer Division

Ok, that clarifies things. I'll get into the habit of checking my errorlist before saving a XAML file.

Friday, January 11, 2008 7:16:00 AM (Eastern Standard Time, UTC-05:00)  #    Comments [3] -
WPF
 Wednesday, September 05, 2007

Somasegar blogs:

I am very pleased to say that we have delivered on that promise and today we announced the release of Silverlight 1.0 as well as Expression Encoder 1.0.  Both are available on the web today! 

Wednesday, September 05, 2007 12:14:43 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Thursday, August 23, 2007

Microsoft has created a very cool experimental interface for searching the web, implementing a Silverlight based userinterface on top of Live Search.

Testdrive it at: http://www.tafiti.com

Thursday, August 23, 2007 12:20:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
General | WPF
 Friday, July 27, 2007

This is a question I've been getting quite a bit lately. People have heard about it, but don't quite know what it is.

www.silverlight.net says it is:
Microsoft® Silverlight™ is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web. Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. Silverlight supports fast, cost-effective delivery of high-quality video to all major browsers running on the Mac OS or Windows.

So what does it boil down to?

Microsoft Silverlight is something you install in your browser which allows you to view Silverlight content.

Silverlight content can be closely compared with Adobe Flash: rich design, animations, a statefull application that runs in the browser.

Silverlight is supposed to have better capabilities in integrating streaming video within your Silverlight application/website than Flash, but not having much experience with delivering video I can't tell from personal experience.

Silverlight content can be written using JavaScript or one of the many .NET languages.

Note 1: As of right now the plug-ins and tools for writing Silverlight content are still in beta.
Note 2: Silverlight was developed as WPF/E, which stands for Windows Presentation Foundation/Everywhere.
Note 3: Silverlight content can be viewed on Microsoft and Mac platforms. Novell has pledged a browser control based on Mono called Moonlight. This will bring Silverlight to the Linux platforms also.

Friday, July 27, 2007 12:51:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | WPF
 Tuesday, February 27, 2007

Here are the powerpoint and demo code from my session about developing for Windows Vista using .NET 3.0 at the Maine Developer Network user group meeting on the 27th of February 2007 in Augusta, ME.

WorkflowConsoleApplication1.zip (35.87 KB)

HelloWorldGadget.zip (14.31 KB)

02-27-2007_MDN_-_Developing_for_Vista_with_.NET_3.0.zip (417.06 KB)

[Updated: Fixed download link for powerpoint]

 

 



Individuals who have been in web development for quite some time, are now slowly converting to internet advertising. Working with tools for web design gives them an added benefit of course. They already have background knowledge on dedicated hosting. All they need is a cheap web hosting service and they can actually start an seo consultancy of their own. Usually pay per click and adsense does not agree with these people. More creative strategies like email marketing appeals to them.

Tuesday, February 27, 2007 9:05:46 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | Vista | WPF
 Wednesday, February 14, 2007

Chris Bowen (Microsoft Developer Evangalist for New England) and Bob Familiar will be touring New England with a roadshow about development on the .NET 3.0.

Roadshow Schedule and Registration

Rochester, NY

February 27th, 2007

8:30am-4:00pm

Click Here to Register!

Burlington, VT

March 1st, 2007

8:30am-4:00pm

Click Here to Register!

Portland, ME

March 6th, 2007

8:30am-4:00pm

Click Here to Register!

Manchester, NH

March 8th, 2007

8:30am-4:00pm

Click Here to Register!

Farmington, CT

March 20th, 2007

8:30am-4:00pm

Click Here to Register!

Wednesday, February 14, 2007 8:45:25 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Vista | WF | WPF
 Wednesday, January 17, 2007

I'll be doing two sessions at the next meeting of the Maine Developer Network user group.

Go to: http://www.maine-devnet.org/Home/Default.aspx to sign up!

Topic       : Implementing application logic in .NET 2.0
Speaker     : Mark Blomsma
Date        : February 27th, 2007
Time        : 10:00 - 12:00
Location    : TBA
Description : This session will be about implementing business logic in .NET 2.0. We'll look at and discuss various architectural issues and how to implement design patterns to help create a blueprint of our application. We'll look at choosing and implementing an exception handling strategy and we'll look at various ways data can flow through our application. Lastly we'll look the Smart Client Software Factory and the guidance offered by the Microsoft Patterns and Practices Group.

Topic       : Developing Windows Vista Q&A
Speaker     : Mark Blomsma
Date        : February 27th, 2007
Time        : 12:30 - 13:30 (possibly longer)
Location    : TBA
Description : Question and Answers session about various aspects of developing for Windows Vista. Send in any questions you want answered to mark.blomsma@develop-one.com.
Wednesday, January 17, 2007 11:00:11 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Vista | WF | WPF
 Sunday, September 10, 2006

They're out!

MSDN subscribers can download Windows Vista via http://msdn.microsoft.com/.

If you're running Windows XP and want to try out the .NET Framework 3.0 RC1, then get the bits at http://msdn.microsoft.com/windowsvista/downloads/products/getthebeta/default.aspx

The .NET Framework download is available for everyone. Not just MSDN subscribers.

Sunday, September 10, 2006 11:15:37 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | Vista | WF | WPF
 Friday, August 18, 2006

Ron DeSerranno writes about a new type of webapplication that he has seen that was build using .NET 3.0. He describes a bookstore that is presented to the user in a 3D environment and where the user feels like he or she is in the store.

The part of .NET 3.0 that makes this possible is largely XAML. A new markup language which in it's basic form is simple enough that it may replace HTML and is at the same time extensive enough that it can take on Flash.

Personally I feel that AJAX is a step back in time. And tooling like ATLAS is really just IDE enhancing technology to generate code that has at it's very core still the JavaScript engine which has seen no improvements in the longest time. So while AJAX aims to use the technology available to the full 100% it is based (and limited) on technology from years back.

XAML offers technology which is not looking back, but instead offers a new platform language, using the .NET Framework as it's platform, which aims to use today's hardware to the max. Much more interactive and 3D content is at our fingertips.

Writing this entry I just thought of a great feature for Word 2007. What if you could save a Word document as XAML instead of HTML. I just checked this isn't possible right now, but I think I'll submit a feedback report to Microsoft on that.

Friday, August 18, 2006 3:32:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | WPF
 Monday, May 01, 2006

My article on 'Getting started with WPF' has been published in the Software Developer Magazine and can also be read online at www.sdn.nl

Monday, May 01, 2006 11:27:07 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Tuesday, March 28, 2006

You can now download the powerpoint from my 'Introduction to WPF' session on the download page at www.develop-one.com.

Or download directly from this link: Introduction to WPF.ppt

 

Tuesday, March 28, 2006 8:19:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Monday, March 06, 2006

With WPF we are far more flexible in creating UI solutions since now almost every control can contain other controls.

The classic example being ofcourse the button.
A button cannot just have a text on the surface of the button, it can just as easily have an image.

Example of button with text.

<Button Name="button1">Just text</Button>

Example of button with image.

<Button Name="button1">
 <Image Source="C:\Documents and Settings\Mark\Desktop\banner.jpg" Name="image1" Width="100"/>
</Button>

Now a lot of buttons will have an image and also some text.
With our HTML background we'll probably attempt:

<Button Name="button1">
 Just text<br/>
 <Image Source="C:\Documents and Settings\Mark\Desktop\banner.jpg" Name="image1" Width="100"/>
</Button>

Wrong! A button can contain controls, but has no 'knowledge' of how to produce a layout for multiple controls.
WPF has special controls that provide layout implementation. These are panels. There are four kinds of panels:
- DockPanel
- StackPanel
- Grid
- Canvas

The same is actually true of the Window control. A Window has no 'default' knowledge of layout. VS2005 will by
default add a 'Grid' control as the root panel.

A StackPanel is easiest to use. It will stack items either horizontally or vertically.
In our button example we would want to use the StackPanel as the child of our Button.

<Button Name="button1">
  <StackPanel Orientation="Vertical">
    <TextBlock>Just text</TextBlock>
    <Image Source="C:\Documents and Settings\Mark\Desktop\banner.jpg" Name="image1" Width="100"/>
  </StackPanel>
</Button>

Notice that we don't need the <BR> tag anymore.
The linefeed is really layout information and our StackPanel is in charge of layouting the content.
If however we have a lot of text, then we could put a newline within the TextBlock.

<Button Name="button1">
  <StackPanel Orientation="Vertical">
    <TextBlock>
      Just text
      <LineBreak/>
      The next line
    </TextBlock>
    <Image Source="C:\Documents and Settings\Mark\Desktop\banner.jpg" Name="image1" Width="100"/>
  </StackPanel>
</Button>

A Grid offers more options and acts much more like a table with rows and columns. I'll show a quick example:

<Grid ShowGridLines="True">
  <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition/>
    <ColumnDefinition/>
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition/>
    <RowDefinition/>
    <RowDefinition/>
  </Grid.RowDefinitions>
  <TextBlock Grid.Column="0" Grid.Row="0">Top left</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="1">Middle</TextBlock>
  <TextBlock Grid.Column="2" Grid.Row="2">Bottom right</TextBlock>
  <Image Source="C:\Documents and Settings\Mark\Desktop\banner.jpg" Name="image1"
      Width="50" Grid.Column="1" Grid.Row="0"/>
</Grid>

As you can see the content of an actual cell is not placed in the cell, but instead the content is listed below the column and row definitions. I must say that I'm still getting used to this notation.

The DockPanel allows you to dock content to a border of the window.
The Canvas panel performs no layout functionality, you're in charge of all layout matters. Much the way 'regular' WinForms let you do all the layouting.

 

Monday, March 06, 2006 8:51:07 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Sunday, March 05, 2006

WPF introduces EventBubbling. People who have done scripting in Internet Explorer will find this very familiar. The concept is that an eventhandler may not be implemented on a GUI-control, but can also be implemented on the parent of that GUI-control. When an event is fired it will traverse the tree from child to parent to parent to parent until it reaches the top control, usually the window.

Let's look at a demo.

Below is the XAML file for Window1.

<Window x:Class="Demo3.EventHandling.Window1"
    xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
    xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
    Title="Demo3.EventHandling"
    >
    <Grid>
    <Button VerticalAlignment="Stretch" Click="button1_Click"
            HorizontalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="1"
            Grid.Row="0" Grid.RowSpan="1" Margin="80,85,77,121"
            Width="NaN" Height="NaN" Name="button1">
      <StackPanel Orientation="Vertical">
        <Image Source="C:\Documents and Settings\Mark\Desktop\banner.jpg" Name="image1"/>
        <TextBox Name="textbox1" Text="Type your name here!" Height="20" Width="333" />
        <Button Name="innerButton" Click="innerButton_Click">Press me!</Button>
      </StackPanel>
    </Button>
  </Grid>
</Window>

Here is the code.

void button1_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("Hello " + this.textbox1.Text);
    Button source = e.OriginalSource as Button;
    if (source != null)
    {
        MessageBox.Show("The original source is: " + source.Name);
    }
}

void innerButton_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("Hello SDN!");
}

This will look like:


Just click on the various controls. Notice that controls that do not have a 'Click' event do not participate in the routing, but may still pass the event on.

In WPF this concept is called event routing. You can halt the routing of an event by setting

e.Halted = true;

 

 

Sunday, March 05, 2006 4:37:49 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF

In the System.Windows namespace there is an 'Application' object. Your application should make use of this class since it allows for lifetime tracking through events like StartUp and SessionEnding and methods like Run.

We can expand our hello world to:

using System;
using System.Windows;


namespace HelloWorld
{
    public class MyApp : Application
    {
        [STAThread]
        static void Main(string[] args)
        {
            MyApp app = new MyApp();
            app.Startup += app.OnApplicationStart;
            app.Run(args);
        }


        void OnApplicationStart(object sender, StartupEventArgs e)
        {
            Window w = new Window();
            w.Title = "Mark says: Hello World!";
            w.Show();
        }
    }
}

With a little bit of digging around you can find the code that Visual Studio uses for initializing the application:


public partial class MyApp : System.Windows.Application
{
    /// <summary>
    /// InitializeComponent
    /// </summary>
    public void InitializeComponent()
    {
        this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative);
        System.Uri resourceLocater = new System.Uri("myapp.baml", System.UriKind.RelativeOrAbsolute);
        System.Windows.Application.LoadComponent(this, resourceLocater);
    }



    /// <summary>
    /// Application Entry Point.
    /// </summary>
    [System.STAThreadAttribute()]
    public static int Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.SetApartmentState(System.Threading.ApartmentState.STA);
        MyApp app = new MyApp();
        app.InitializeComponent();
        return app.Run(args);
    }
}

As you can see some resources are initialized in the InitializeComponent. By default the VS2005 WinFx project sets up some resources, you find them under the 'Properties' folder. Also an URI is set to track the initial window. This URI is the window that will be started when app.Run(..) is executed.

 

Sunday, March 05, 2006 3:40:50 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF

Time to continue with WPF.

You don't need to use XAML to program WPF. Quite the contrary. Everything you can do with XAML you can do with C#. It's just a matter of using the right tool for the right job. It doesn't make much sense to do all the layout code in C#, XAML will hopefully do a better job there. Anyway, just to prove the point I have to start where every new technology starts: Hello World!

I've installed all the necessary tools. I've started VS2005 and created a new WinFx application.
The application by default holds references to all relevant assemblies, these being:
- PresentationCode
- PresentationFramework
- ReachFramework
- UIAutomationProvider
- UIAutomationTypes
- WindowsBase

The names of these assemblies don't look very RTM-like, so I have to assume they'll change in one of the upcoming CTP's or RTM.

I like to start as clean as possible, so I throw out all the stuff under the properties folder and also the default created MyApp.xaml and Class1.xaml.

Now add a new class called HelloWorld:


using System;
using System.Windows;  //This is the WPF namespace

namespace HelloWorld
{
    public class HelloWorld
    {
        [STAThread]
        public static void Main()
        {
            // This is the System.Windows.MessageBox
            MessageBox.Show("Hello SDN!");           
        }

    }
}

Startup the application and go!

Sunday, March 05, 2006 3:16:26 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Thursday, March 02, 2006

Mike Henderlight blogs that the "Crossbow"-technology will actually be part of WPF.

"We have spent the last several months working very hard on developing and executing on a plan where we could deliver the Crossbow runtime as an integral part of WPF.  As of the Beta2 release of WPF, the Crossbow runtime will be part of the WPF redist and reside in the GAC just like all of the other WPF components.  And from that point forward we will be on the WPF ship schedule which means that we will RTM with WPF."

This is great! The Crossbow-technology has been created by a seperate team within Microsoft, but I'm sure when WPF hits the streets most developers will assume this to be a very "oh yeah, there is interop with WinForms, what's new" kind of feature. You know? One that everyone expects to be there, but is really very very cool.

Thursday, March 02, 2006 1:45:24 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Thursday, February 23, 2006

The February CTP build of the WinFX SDK and also the Orcas February CTP will both feature Crossbow.

Crossbow will allow you to use WPF functionality on existing Windows Forms.

Read more on: http://blogs.msdn.com/mhendersblog/archive/2006/02/01/522723.aspx

Update:

There is also an MSDN show on MSDNtv: http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060216CrossbowMH/manifest.xml

Thursday, February 23, 2006 4:07:26 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF

The February CTP is now available for download, also the WinFX release candidate is available on the same page:

http://msdn.microsoft.com/windowsvista/getthebeta/default.aspx

A list of breaking changes between this and the January CTP has been posted here:

http://windowscommunication.net/collateral/pages/BreakingChangesJanCTPToFebCTP.htm

Thursday, February 23, 2006 4:45:56 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Vista | WPF
 Saturday, February 11, 2006

So you're a developer and you want to get started with Windows Presentation Foundation (a.k.a.) Avalon?
Well here are the steps I took to play around with this new and hip technology:

  1. Create a fresh VirtualPC image with WindowsXP SP2. I read that you can also use Windows Server 2003 if you wish.
  2. Install Visual Studio 2005. I use Professional edition, but the beta's also work with the Visual Studio Express editions.
  3. Download the WinFX software developer kit at: http://msdn.microsoft.com/windowsvista/getthebeta/default.aspx 
    I've downloaded the WinFX RTC plus the VS2005 extensions.
    Note that if you want to install the VS2005 extensions you also need to download the Windows SDK beta.
    If you don't install the SDK the VS2005 extensions will show a message saying that you need to install the Windows SDK and then also make sure that you install the beta SDK, the regular SDK will not suffice!
    Feels like my WindowsXP machine is being turned into a Vista machine already :-)
  4. Install the WinFx RTC download. The installer will want to download another 16MB of data, so make sure your VirtualPC environment has Internet access.
  5. Install the Windows SDK beta.
  6. Install the VS2005 Extensions package.
  7. Install the VS2005 Extensions for Windows Workflow Foundation. These are obviously optional for playing around with the WPF beta, but since we're setting up a play area we might as well get it complete.

Done? Okay, time to test to see if all is well.

Make a little test XAML application, it ofcourse has to be:

a) Use notepad to create a file called 'test.xaml'
b) Copy code below into file.

<Page xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
   <TextBlock>Hello World!</TextBlock>
</Page>

c) Save
d) Double click the file.
e) Yeah! A real life XAML application.

I also tried placing this test file on my webserver ( http://www.develop-one.net/presentations/code/wfm/test.xaml ) but opening this URL results in a security exception. I'll look into that some more later. Probably still need to add this URL my Trusted sites.

 


 

Saturday, February 11, 2006 3:11:12 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Wednesday, February 08, 2006

I've just been confirmed as a speaker at the Software Developer Event, the 24th of March 2006 in Ede, The Netherlands. I'll be doing an exciting session about Windows Presentation Foundation, a.k.a. Avalon.

For more information read the session abstract below. Hope to see you there!

Working with Windows Presentation Foundation
This introductory session about Windows Presentation Foundation, formerly known as Avalon, consists of two parts. The first part is about the WPF fundamentals. Here the developer will get 'a look under the hood' in order to get a better understanding of what is happening when developing a WPF application. The second part of the session looks at two tools that can be used to actually develop a WPF application and be productive while doing it, because who really wants to manually program XAML, right? The first tool we'll look at is codenamed 'Cider'. This tool allows a developer to create WinForm-like applications with WPF. The second tool is codenamed 'Sparkle' and is used for creating more Flash-like applications.

Wednesday, February 08, 2006 1:14:18 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Monday, January 30, 2006

Microsoft has released a draft version of the design guidelines for Windows Vista.

Surf to: http://www.microsoft.com/downloads/details.aspx?FamilyId=FD380553-911E-4659-A085-4DD58AE4B9AE&displaylang=en

Monday, January 30, 2006 8:35:50 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
General | WPF
 Tuesday, January 24, 2006

Microsoft has released a preview of it's tool for editing XAML. The codename used to be Sparkle, the production name will be Expression Interactive Designer.

Read more on Manuel Clement's blog: http://spaces.msn.com/members/manodesign/Blog/cns!1pRsSVBaAuwgFSti-clSJ6Ng!384.entry

Tuesday, January 24, 2006 8:53:44 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WPF
 Saturday, January 14, 2006

Just a couple of links to stuff that's in beta right now:

WinFX, XAML and SDK
ASP.NET ATLAS
C# and LINQ
VB.NET and LINQ

Saturday, January 14, 2006 10:37:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.NET | C# | LINQ | WPF

I'm finally catching up on some reading that I've been meaning to do.

Right now I'm reading 'Programming Windows Presentation Foundation' by Chris Sells & Ian Griffiths. Good read and I hope to finish it on my next flight :-)

Also spend some time this morning reading an article by Ted Neward on MSDN (http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/linqcomparisons.asp) which gives food for thought on LINQ and the whole OR-mapping issue.

Saturday, January 14, 2006 10:13:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ | WPF
About
This blog is run by Mark Blomsma.
© Copyright 2008
Develop-One
Sign In
Statistics
Total Posts: 305
This Year: 49
This Month: 2
This Week: 1
Comments: 36
All Content © 2008, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)