Tech Tock

Time is of the essence.

Losing my Memory

After fixing the classic event handler reference memory leak, I uncovered a WPF memory leak in my application.  It seems that WPF itself has a memory issue in the way it tries to lazy load dictionary resources.

I had a lot of additional memory in snapshot diffs being taken up by DeferredAppResourceReference objects.  There seems to be a Hotfix that addresses the issue, but I found a decent code solution by Andrew S on MSDN.  This code will instantiate the dictionary objects on startup, avoiding the buggy MS lazy loading.

public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
WalkDictionary(this.Resources);

base.OnStartup(e);
}

private static void WalkDictionary(ResourceDictionary resources)
{
foreach (DictionaryEntry entry in resources)
{
}

foreach (ResourceDictionary rd in resources.MergedDictionaries)
WalkDictionary(rd);
}
}

 

 

Ironically, now one of the largest growth objects in my app is WeakReference.

January 31, 2011 Posted by | Uncategorized | , , | 1 Comment

WPF MetUp

I had a great time presenting at the .Net Meetup last week.  It was a lively discussion thanks to everyone who showed up.  David Barnhill gave me great support and his extensive knowledge and experience really added depth to the conversation.  Everyone’s feedback and prompting was just great and it was very interactive.

Thanks everybody.

Some of what we covered:

WPF is not the same old system.  Some older ways of doing things in WinForms are just alien to the WPF paradigm.  Extensive use of UI inheritance is out.  Use of templates and Prism is in.

WPF is 4 years old and still early in the adoption cycle.  Paradoxically, this is because its so good.  Its entirely revolutionary (at least compared to WinForms) and so different from what came before that in some ways its like starting over.  This leads to learning curves, staffing and project delivery issues during adoption.

The question is what does it really do for business?  The main thing is that you can do more.  Many things you may not have attempted in WinForms are done simply in WPF.

But how do you get started with WPF?  Same as any new technology I suppose:

  • Read the books.  WPF Unleashed is the top recommendation.
  • The videos on Channel9 are great.
  • There’s more videos from Microsoft here and here.
  • Jason Dolinger’s MVVM video is a classic.
  • Take training.
  • Hire an experienced WPF developer to join the team or bring in a consultant to help out on your first project.  A mentor is invaluable when starting out.
  • You can use WPF simply to start.  Don’t try to use every feature, just get the basics. At its most simple its not so different from WinForms.
  • You can have WPF controls, modules and/or pages in a WinForms app and vice versa so it can come slowly into an organization even with a legacy application.

September 27, 2010 Posted by | Uncategorized | , , , | Leave a Comment

INotify Snippet Update

Here’s an update to my INotify snippet.  The only change is that I took out an unnecessary ref from the CheckPropertyChanged signature.  Now I’m hosting the code at google so its easier to keep updated.

protected bool CheckPropertyChanged<T>(string propertyName, ref T oldValue, (no ref here)  T newValue)

September 15, 2010 Posted by | Uncategorized | , , , , | Leave a Comment

Oh, The Things You Can Do With WPF

Here’s an animation I made for my upcoming WPF presentation.

You can download the code here, but you might want to wait till after the presentation when it will be finished.

September 13, 2010 Posted by | Uncategorized | , , | 3 Comments

WPF in 60 Seconds

Or:  So Much WPF, So Little Time

I’ll be presenting on WPF at the September 21st .Net Meetup.

A breezy tour of topics in WPF from the ground up with demo examples and source code.  Each topic will be given a one minute treatment.  For anyone interested in, new to, or learning WPF you can see the scope of the platform and see what you want to learn.  For anyone working in WPF, enjoy the highlights of your platform.  You might even see something you’ve missed.

Everything will apply equally to Silverlight, subject of course to this diagram.

August 11, 2010 Posted by | Uncategorized | , , , | 2 Comments

@Lab

Welcome Aboard Jimmy Schementi

IronRuby core team member, Jimmy Schementi, is joining Lab49.  Read about his decision here.  MS bashing here.

Meetup

I caught David Padbury’s WPF/Blend demo at the July .Net Meetup.  He really made it look easy and the demonstrated behaviors were pretty cool.

I’ll be presenting on WPF at the September 21st .Net Meetup.

Coming Soon

For the worlds most useful WPF XAML Converter watch this space.  It even beats BooleanToVisibilityConverter IMHO!  It’s brilliant simplicity.

Grid Computing

Lots of grid computing talk.  Data Grid, Computation Grid, whatever, it all sounds pretty whiz bang cool to me.

Here’s some links.

Papers: http://www.globus.org/alliance/publications/papers.php

Software:

Globus: “the daddy of grid computing software”
Coherence: http://download.oracle.com/docs/cd/E15357_01/index.htm
Gemfire: http://www.gemstone.com/docs/6.0.1/product/docs/
EHCache (including Terracotta distribution option): http://ehcache.org/documentation/index.html
Hadoop: http://hadoop.apache.org/
http://jboss.org/infinispan
http://gridgain.com/

Web 3.0 is here – All Hail Web 4.0

http://byronmiller.typepad.com/byronmiller/2007/07/just-when-you-t.html

Access Memory Directly At Your Own Risk

Here’s some instructions on how to access memory directly in JAVA.  Use caution.

Canonical Data Models Considered Harmful

It's BeautifulThe Shangri-La of a single all encompassing data model for disparate business units will mostly likely become a tortuous chimera.

Peccavi

I missed the Lab Seminar Presentation on time management – maybe that’s a primary indication I should have gone.

August 9, 2010 Posted by | Uncategorized | , , , , , | Leave a Comment

EventToCommand for Attached Property

To propagate events to a view to a ViewModel – use an attached property, not fancy xaml binding, but an attached property.  It says so right here in so many words.  So if you want MouseOver or DoubleClick, AutoComplete.Populating, etc. this is your answer.

Here’s the example everyone points you to.

The all purpose EventToCommand class in the MVVM Light Toolkit looks like the most convenient way to get this job done.

For any type of click, retemplating a button and using a ViewModel ICommand for its Command is the way to go.

August 6, 2010 Posted by | Uncategorized | , | 2 Comments

Cider – A Bitter Brew

Cider is the name for that incredibly slow and useless XAML preview in Visual Studio 2008.  Instructions on how to turn it off can be found here.

July 22, 2010 Posted by | Uncategorized | , , , | Leave a Comment

ContentTemplate for Blendability

Was working on a medium sized DataTemplate that lost Blendability.  Extracted the piece I wanted to work on into a new DataTemplate and connected it with a simple ContentControl.  Problem solved (ish).

<DataTemplate x:Key=”ExtractedTempalate”>

<!—stuff you are interested in – make this blendable – probably not too hard for a small section –>
<Controls XXX=”any needed items here” />
</DataTemplate>

<DataTemplate x:Key=”UnBlendableTemplate” >

<!– lots of stuff you’re not interested in right now … –>

<ContentControl
Content=”{StaticResource ExtractedTempalate}”
Content=”{Binding}” />

<!– lots of stuff you’re not interested in right now … –>
</DataTemplate>

July 14, 2010 Posted by | Uncategorized | , | Leave a Comment

WPF Checkbox – Pheh!

I got into this stupid problem with a WPF checkbox. Basically, with some code in the ViewModel, the checkbox doesn’t show the check when it gets clicked.  The control doesn’t check the value when NotifyPropertyChange is called.  I saw a claim that its an issue with possible infinite recursion.  Just an annoyance to me.

My workaround was to switch to the Infragistics XamCheckEditor.  If a little control like that doesn’t want to work I don’t want to write some nasty code to fix it.  To heck with it.

Then I noticed that a click on the textblock didn’t trigger the check with this setup.  Basically:

<XamCheckEditor><TextBlock /></XamCheckEditor>

I tried the regular checkbox again and probably since I had made a few code changes, it worked.

But still.  Pheh.

July 6, 2010 Posted by | Uncategorized | | Leave a Comment

Follow

Get every new post delivered to your Inbox.