WPF
Originally published on my old Charteris blog This is part 6 of the training course originally described here with parts 2,3, 4 and 5 available here, here, here and here respectively. So far we have covered WPF fundamentals, XAML, brushes, shapes, controls, styling, resources and layout. Part6 Data Binding class Converter property ...
Originally published on my old Charteris blog
Debugging layout issues is something I had to do fairly often particularly with some of the complex layouts we were trying in the past. Trying to work out why "such and such" FrameworkElement would not stretch to the size of "whatever" layout panel I was using.
Before we get to the detail of stretching there is one simple layout, debugging technique that I think is worth sharing; It is that setting the backgrounds of all the various panels that you are using, whilst debugging, makes life much easier. Take this relatively simple layout problem
Imagine if we are trying to find work out...
Originally published on my old Charteris blog This is part 5 of the training course originally described here with parts 2,3 and 4 available here, here and here respectively. So far we have covered WPF fundamentals, XAML, brushes, shapes, controls, styling and resources. Again if anyone wants to contact me for clarifications or to talk over part of the course just use a Comment or the Contact link at the top of the page. Good luck! The details of part 5 are below, the labs and any associated code are in the download package. LAB...
Originally published on my old Charteris blog This is part 4 of the training course originally described here with parts 2 & 3 available here and here respectively. So far we have covered WPF fundamentals, XAML, brushes, shapes, controls and control templating. Again if anyone wants to contact me for clarifications or to talk over part of the course just use a Comment or the Contact link at the top of the page. Good luck! The details of part 4 are below, the labs and any associated code are in the download package ...
Originally published on my old Charteris blog This is part 3 of the training course originally described here with part 2 available here. From this part onwards the course tends to concentrate more on labs and classroom interaction than on plain slide content. This worked great in a classroom scenario but it may make it hard otherwise. I have edited some of the downloadable slides to make them easier to read in isolation. Again if anyone wants to contact me for clarifications or to talk over part of the course just use a Comment or the Contact...
Originally published on my old Charteris blog This is part 2 of a training course I originally put together for the Charteris team and am now posting online. See here for the original Post and details on Part1 Part2 2D Graphics Colour and RGB Brushes SolidColorBrush VisualBrush ...
Originally published on my old Charteris blog Back in April I was asked to put together a training course on Windows Presentation Foundation (WPF) for the Charteris team. The course was well received here and it was agreed that after a bit of time I could release it publically. So I am going to make most the course available here. I will post it in parts and I am happy to take questions, clarifications and comments about each part. Each one will include the relevant powerpoint slides and relevant labs, with code to start you off. Part1 ...
Originally published on my old Charteris blog
So out of the box WPF's default template will use a VirtualizingStackPanel. The virtualizing part of the VirtualizingStackPanel (VSP) is that it will only generate the UI elements for the items that are currently visible on screen. This can have big benefits when you are working with a large dataset and complex UI.
Things to remember if you think virtualization is not happening
Make sure that ScrollViewer.CanContentScroll is set to True & IsVirtualizing is set to True. These are ListBox's defaults but remember them if you are customising the ListBox...
Originally published on my old Charteris blog
Just as Reflector is great learning tool for seeing how Microsoft put together their .Net class libraries ShowMeTheTemplate! is a great learning tool for seeing how Microsoft put together the control Templates for the standard WPF Controls.
They are good example of the use of TemplateBinding and how you should respect the properties that a consumer has set on the control you are retemplating.
Originally published on my old Charteris blog
I am blogging this for my own benefit as much as anyone else's because I am always forgetting this relatively simple thing.
Often in XAML you will need to specify a property by class and member such as "Image.IsMouseOver". This simple syntax is straight forward, easy to remember, and known as PropertyPath syntax. What is not so obvious is that you can move down the object hierarchy to access child properties. I needed to do this today and it is this that prompted my post.
On the Loaded event of an Image, in a...
Originally published on my old Charteris blog
Those people who have come to WPF in the last 3 or 4 months are rather spoilt with WPF editing tools like Expression Blend and the editor in Visual Studio (Orcas) release codenamed Cider. However don't forget XamlPad. XAMLPad.exe gets installed as part of the Windows .NET 3.0 SDK and it's a quick and simple way to put together samples and ideas. Some time around Beta 2 of WinFx XamlPad was updated and got the very useful Visual Tree Explorer.
This gives you a read only view of the visual tree and is particularly...
Originally published on my old Charteris blog
Richard contacted me today because he was having trouble binding a ListBox’s ContextMenu to data belonging to the SelectedItem. My initial thought was binding statement like this
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{Binding Path=SelectedIndex,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListBox}}}" />
</ContextMenu>
</ListBox.ContextMenu>
RelativeSource tells the binding looking for the source of the binding and the way it does this is dependent on the mode. The four, supported modes are
FindAncestor...
Originally published on my old Charteris blog
Whilst working on my graph control a couple of nights ago I found that I needed to have the values of my X axis stacked with the first item at the bottom and the last at the top. I was using the ItemsPanel default of a StackPanel, this StackPanel element does give you some control over how the items are stacked using the Orientation property. Unfortunately that only goes as far as saying “stack horizontally or vertically”.
My first thought was create a custom implementation of the StackPanel adding the ability to invert the...
Originally published on my old Charteris blog
As I said before WPF data binding, along with the various types of triggers, helps keep the minutiae of UI logic out of your “code behind”. I am amazed by what can be done with just XAML, I was fortunate enough to have a conversation with one of the Microsoft Max team a few weeks back and they he was very keen to explain how much can be done in just XAML.
Therefore I try hard, very hard to keep my UI to XAML but sometimes the binding XML is just too simplistic. Imagine this,...
Originally published on my old Charteris blog
I first came across DOM explorers\inspectors for web browser DOMs last year and found them an absolute godsend. Any web developer who has never used one get to it! The Firefox DOM inspector ships with the browser and is available if you check the "Developer Tools" option at install time, read more about here. The Internet Explorer one is part of the Web Developer Toolbar and can be installed from here.
When I came to smart client development with WPF I never expected to find something as useful and as revealing as a DOM inspector. Well Pete...
Originally published on my old Charteris blog
Whilst trying to debug some fairly complex 3D animations recently I happened upon the SpeedRatio property. It is a property of the Timeline class and therefore all the classes that inherit from it such as Storyboard .
Basically this property allows you to put your animations into slow motion; the value must be from 0 to 1.0 with 0.5 being half speed. Now you could achieve a similar thing with the Duration property and doubling the duration but what you will often find with more involved animations is those children Storyboards and Animations will...
Originally published on my old Charteris blog
A few months back I was looking at getting HD installed and the satellite TV company's website had this nice animation were they made the text appear bit by bit like it was being decoded before your eyes. The animation is about 4 levels deep in a Flash movie so I cannot link to it directly but it reminds me of the way the number 24 is animated in the series "24".
I thought I would take a look at how wold do it in WPF. I found there was not much for string...