Tuesday, 31 July 2007

More new WPF 3.5 things

Neil passed me some of these URLs in my comments and i'm all too happy to republish them.

Technorati Tags: , , , ,

Monday, 30 July 2007

WPF / Control interop, the blended way...

More of a bookmark for later, but seems Leslie and Jeremiah are doing fancy stuff with win32 controls and getting rid of the Hwnd limitation. Well done!

Edit: Leslie gave the link to the source code in the comments, so here it is. Thanks Leslie! http://www.codeplex.com/WPFWin32Renderer/Release

Technorati Tags: , , , , ,

A Bit of WPF love. No, Bits of it!

Tim Sneath posted an answer to the question I asked on friday (well, posted something that answered my question, probably without him being aware of it in the first place):

Most of the performance improvements and some of the feature improvements will also be included in a forthcoming service pack for .NET Framework 3.0 - I don't think we've talked externally about delivery mechanisms for this at this stage, however.

Good news! So I was right, there is a service pack in the pipeline!

Friday, 27 July 2007

So there *are* new things for WPF in 3.5

Visual Studio 2008 beta 2 has just been released, and with it an announcement of new features and bug fixes for WPF. And the best bit for me:

Data binding and journaling by URI work together.

For the WPF application we released to National Express with Netstore, this bug hit us very hard, as we designed a whole navigation system based on passing context / data objects around while keeping navigation by URL (memory footprint being the main reason why you want to navigate by URL.) What used to happen was that any Binding associated with a dependency property that supported Journaling would not be re-established. My good friend Neil Mosafi (seems to not have a blog anymore) was the one that found the bug.

Question for Microsoft though, is there going to be a HotFix for the issue? Some applications in the wild would definitely benefit from having a fix, rather than rely on inheriting every control and overriding each journaled dependency property manually.

As I'm writing this entry, my mind wanders and hope that one day WPF applications will work more like the browser, keeping a page as KeepAlive for a known number of pages or memory footprint, and only release a page when the history stack takes up too much memory. Maybe in .net 4 with WPF (which would be wpf 2.0, if 3.5 is WPF 1.5. Interesting arithmetic, WPF = .net - 2).

Oh the thrill. I'll be starting cooking some WPF examples next week as soon as I switch back to booting Vista instead of MacOS X (have a look at VMWare Fusion. Now if they could integrate their Unity feature with the vista DWM, I could get accelerated graphics WPF development in visual studio within macos. Hmmm...)

Technorati Tags: , ,

Thursday, 19 July 2007

The future soon

After a nice time at AKQA, I'm off in a week time to a big media company for some super duper secret WPF project I obviously won't talk about. But that means WPF content is going to re-surface en force. My WPF tips'n'tricks need to be followed on.

And thanks to the comments and emails I've received from some of the people reading me, if I've been of any help then it's all worth it.

Oh, and I bought a new high resolution MacBook Pro, fantastic Vista development machine! This one is insured though.

Wednesday, 11 July 2007

PowerShell arguments and encodings

Well, after fighting for an hour or two, I finally read a post explaining why my quotes were not passed around when invoking a script. Now that I'm using the -EncodedCommand attribute, everything works fine!

As the guys on the powershell team wrote about encoding conversion, I thought I'd provide two quick ones for those needing it, Url Encoding and Base64. Don't hesitate to add to your profile.

Note that I'm using LoadWithPartialName because I'm lazy and it still works on .net 2. Replace with proper LoadFrom or Load as needed.

[System.Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null
function ConvertTo-UrlEncodedString([string]$dataToConvert)
{
    begin {
        function EncodeCore([string]$data) { return [System.Web.HttpUtility]::UrlEncode($data) }
    }
    process { if ($_ -as [string]) { EncodeCore($_) } }
    end { if ($dataToConvert) { EncodeCore($dataToConvert) } }
}
function ConvertFrom-UrlEncodedString([string]$dataToConvert)
{
    begin {
        function DecodeCore([string]$data) { return [System.Web.HttpUtility]::UrlDecode($data) }
    }
    process { if ($_ -as [string]) { DecodeCore($_) } }
    end { if ($dataToConvert) { DecodeCore($dataToConvert) } }
}
function ConvertTo-Base64EncodedString([string]$dataToConvert)
{
    begin {
        function EncodeCore([string]$data) { return [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($data)) }
    }
    process { if ($_ -as [string]) { EncodeCore($_) } }
    end { if ($dataToConvert) { EncodeCore($dataToConvert) } }
}
function ConvertFrom-Base64EncodedString([string]$dataToConvert)
{
    begin {
        function DecodeCore([string]$data) { return [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($data)) }
    }
    process { if ($_ -as [string]) { DecodeCore($_) } }
    end { if ($dataToConvert) { DecodeCore($dataToConvert) } }
}

 

Technorati Tags: , , ,

Friday, 29 June 2007

WPF Attached Events Addendum

Some of you may remember my article on attached events. There's now more clarification from the WPF SDK blog. Considering the extensive email exchange I had with Wolf Schmidt about the topic and its coverage in the SDK, I wouldn't be surprised if he had something to do with that article. An excerpt from our conversation is in order.

Now that I've spent so much time on an email to one individual customer, I think I smell a WPF SDK blog entry coming :-)

The point is, the MSDN people are very accessible and very helpful, and answer with passion and accuracy. And they hang on the WPF forum as well so don't hesitate to drop your questions there.

Technorati Tags: , ,

Service Pack on the way?

A while ago, Rob Relyea mentioned on the forums that they had someone working on community and bugs in the WPF team.

I also remember reading a few days ago a Microsoft blogger talking about a service pack.

And Neil has pointed out that bugs are starting to get closed down on the Connect site.

And now, another proof, in the form of a link list:

Service pack may you come. And if other bugs could be fixed, including the dependency property journaling and persistence counter for user controls, that would be nice Microsoft :)

 

Technorati Tags: , , ,

Wednesday, 27 June 2007

Multiple mice and cursors on WPF applications

For those that want to do WPF development with multiple cursors, Microsoft released a new version of the MultiPoint SDK. 

Download details: Microsoft Windows MultiPoint Software Development Kit (SDK)

Technorati Tags:

Knowing which aliases are defined

[Update: Replaced -eq by -match as suggested on the PowerShell blog. Thanks guys, humbling to have you reading this blog. Tagging really does have a use :) ]

One of the main struggles I have when writing my PowerShell scripts for public consumption is that I never remember which aliases I can use. And eventually I'd like to naturally type gci instead of ls, but old habits die hard.

Here's a little function I have in my profile to get the list of all aliases defined for a command.

function Get-AliasShortcut([string]$CommandName) {
    ls Alias: | ?{ $_.Definition -match $CommandName }
}
Set-Alias gas Get-AliasShortcut

Which you can then execute as such:

6# gas get-childitem

CommandType     Name                                                Definition
-----------     ----                                                ----------
Alias           gci                                                 Get-ChildItem
Alias           ls                                                  Get-ChildItem
Alias           dir                                                 Get-ChildItem

Technorati Tags:

Tuesday, 26 June 2007

Stupid word of the day

Heard in a corridor.

This has great talkability.

Maybe that's why I'll always have trouble with marketing. Of course the simplest form I can think of,

This will make people talk.

doesn't have the same punch. Why remove the people from a marketing slang expression? Probably because marketing people prefer not to think they're manipulating (or is it influencing) humans.

When digital was about digits...

A blog post over on Satisfy me reminded me of the good old Compuserve days. Oh yes I was there, and 100530,3355 was my ID! That was back when the Internet wasn't that big mind you. But we had file transfers with resumable downloads, chat rooms, message boards, and a real sense of community.

But then the Internet arrived and I turned into technoboy@cis.compuserve.com (when alias email addresses were tested, and only the SysOps knew about them (oh the social status it was to be SysOp or even WyzOp! (and I promise to stop nesting braces.)))

And one of the first IM system on the Internet? ICQ of course, where I was 2931484 for years (and I believe that account is still alive).

Isn't it strange how years on (13 years for Compuserve, 11 for ICQ) I remember these numbers but have no memory of any of my passwords or previous email addresses.

Maybe the brain is better at numbers than we think. And maybe I miss the old time when the digital world was about digits.

Monday, 18 June 2007

xsd.exe passed away, svcutil.exe is the way to go

I was reading Darren David's blog entry on code generation from xsd files. Sadly, he references xsd.exe that generates Xml serialization code.

If you're using .net 3, the new kid on the block is svcutil.exe that will generate real DataContracts that will give you a smooth path to Indigo (hmmm, WCF).

Sadly, the documentation focuses mainly on generating the client code rather than the DataContract serialization code. There is one page detailing the process: Importing Schema to Generate Classes. Choose to not generate the client and only generate data contracts from your xsd schema and you'll be done, the v3 way.

Wednesday, 13 June 2007

Quickly know when you're in quirk mode

While debugging an application rendering issue yesterday (yes, I'm back to a bit of asp.net work, with CSS adapters and asp.net AJAX, oh the joy!) I came up with a very quick way to know when you're in quirk mode.

In the address bar, type the following:

javascript: window.alert(document.compatMode);

CSS1Compat means the browser is not in quirk mode.

Simple and efficient, but of course not with frames (which you shouldn't use anyway!)

eScrum

For fans of scrum, Microsoft released eScrum v1. Not had the time yet to investigate it but it looks good!

Tuesday, 12 June 2007

Validation in WPF with Enterprise Library

A very good news for those that require enterprise

Technorati Tags: , ,

quality validation, there's now a project to integrate WPF validation and Enterprise Library Validation Application Block.

Wednesday, 6 June 2007

Silverlight Predictions and WPF Snippets.

On a break from blogging at the moment, service will resume when my new MacBook Pro arrives (new resolution, faster CPU, nvidia chipset and 4gig of memory), and when I finally finish my move in central London. That said, my Silverlight predictions were accurate 100%, except I predicted a beta where both an RC and a CTP were released. And thanks to Brownie Points for enhancing my wpf snippets, although my blog is not notstatic.com and he forgot to give me credits. Hopefully he'll read the trackback and amend his entry. A lot could be said about the addition of UIPropertyMetadata against FrameworkPropertyMetadata. Rule of thumb if you're using WPF, unless you know the difference between the UIElement and the FrameworkElement levels, stick with the Framework layer. In this case, for WPF FrameworkPropertyMetadata is acceptable, for other toolkits only PropertyMetadata would be more accurate.

Tuesday, 24 April 2007

Silverlight big announcement at MIX07?

I was reading the wpfbox blog about the MIX07 announcement regarding Silverlight (the new name for WPF/E). Well if this is the one you're talking about, we've known for some time that wpf/e would include a derivative of the micro CLR that already ran on the short lived SPOT devices, and a lot of work has gone through enabling CLS compliant languages to run on an embbed version of the CLR. My best bet is that compiled IL will be presented at MIX07, together with a beta. Maybe there will even be full interop between IL code and javascript code, letting you call objects coded in C# using javascript.

Wednesday, 11 April 2007

Multiple default buttons the WPF way

Not from me, but from Neil, my future ex-colleague at Netstore: “Default” buttons in WPF and multiple default buttons per page.

Monday, 9 April 2007

WPF Tips'n'Tricks #4: Another way to declare read-only dependency properties

Sorry for the hiatus this week-end, I spent a lovely time out of London, disconnected from the online world. Back online (in the train, with WIFI, fantastic, check it out).

Read-only dependency properties (attached or not) are declared by a call to RegisterReadOnly, which returns a DependencyPropertyKey type, which you have to use when setting values. From that object you get a reference to the DependencyPropert object that is used to read values. Let's look at a typical dependency property registration.

public class Div : Control

{

private static DependencyProperty LeftProperty;

private static DependencyPropertyKey LeftPropertyKey;

static Div()

{

Div.LeftPropertyKey = DependencyProperty.RegisterReadOnly(

"Left",

typeof(double),

typeof(Div),

new FrameworkPropertyMetadata(0d));

Div.LeftProperty = Div.LeftPropertyKey.DependencyProperty;

}

Traditionally, you would then define a property with only a getter. But one of the not so known new features of C# 2.0 is the ability to declare different access modifiers for the getter and the setter of a property. We'll use it to our advantage to declare a property getter but have a private setter using the Key, keeping our object model clean and nifty.

public double Left

{

get { return (double)GetValue(Div.LeftProperty); }

private set { SetValue(Div.LeftPropertyKey, value); }

}

And voila, a nice and clean way to set your read-only properties without calls to SetValue all over the place.

[Edit: Added the private as I forgot it. Thanks for correcting me! ]