Posts Tagged ‘XAML’
March 5th, 2008
Silverlight 2.0 had a Beta release today and I’m currently sitting in the second of two talks about creating rich internet applications with Silverlight. The talk is being done by Joe Stegman and Mike Harsh.
The thing that I’m getting really excited about is the extent to which Silverlight 2.0 XAML actually looks and acts just like WPF XAML. I’ll start looking at Silverlight in the future and posting on it as I figure it out.
If you are brave and daring, however, you can head over to Mike’s post on the talk where he links to all of the files his project is built on.
By the way, if you want to work with Silverlight in Visual Studio or Expression Blend (and I wouldn’t reccomend doing it any other way), you’ll need to download the Silverlight 2.0 Tools for Visual Studio 2008 and the Expression Blend 2.5 March Preview.
I’ve installed them and glanced at them and they are really cool… major steps forward for Silverlight.
More later.
February 27th, 2008
Sorry for the extended absence… I’m been working myself to the bone on the Veracity submission to the Show Off at MIX08. We’ll have some really kicking stuff to play around with at the Open Space… you should drop by and say hi. I look something like this:

At least I look like that at 1:30 AM.
OK, so I felt the need to pipe up at this ungodly hour with a public service announcement about events and databinding. I just spent a good hour trying to figure out a workaround for this problem. I had a method being called on my “IsVisibleChanged” event. I was planning on take that item and performing some code-behind logic based on the databound Canvas.Left and Canvas.Top properties.
WPF put the smack-down on that action. The data binding wouldn’t update before the event was called. And I couldn’t make it. Not without some kind of Invoke… which, I must admit, scares the ever-loving crap out of me, so I didn’t try… also because I didn’t know how to use it.
My advice if your databinding won’t update? Find some way of going to the data itself. If you’re binding to something in the XAML, you should be able to find the object you’re binding to in the code as well. Just go straight to the source.
Anyone have a better idea or suggestion? I’m totally open to hearing it.
February 8th, 2008
One of the questions I get most often from designers and almost never from developers is:
How can I get drop shadows into my application without killing my performance?
It is, of course, easy as punch and pie to get drop shadows into your application. You can just use the Bitmaps Effects panel in the Appearance section:

For the love of God, please do not use the Bitmap Effects in the Appearance section!
If any developers found out that I told you to use BitmapEffects, they would hunt me down and cut off my fingers. This is because, while the Bitmap Effects in WPF are all sorts of cool, they make your computer break down into uncontrollable sobbing. Bitmap Effects hog system resources by requiring software rendering for render-heavy effects. There is no better way to slow down a perfectly good application than to give every other element a drop shadow.
But, what if you really really want to?
Read the rest of this entry »
February 7th, 2008
This is actually a continuation of my post on getting the ComboBox items to accept text wrapping, so I’ll be working from that point forward. If you’re coming fresh into this, you won’t be missing anything… but that is my explaination for the pictures containing wrapping text.
When last we left our heroes, we has a couple problems. The first was that our items were either black text on a white background and ran together in a very un-designer-y way.

The second was that the selected item background makes your eyes bleed such a horrid blue color you’ll feel like Paul Atreides staring at a stone burner.
Was that a little too geek? My apologies.
Read the rest of this entry »
February 7th, 2008
The ComboBox is not the most complex of the WPF applications, but it can be a little tricky, so lets do a general overview post of it before we go into the specifics of how we’re going to make it work.
First of all, if you’re going to test your comboBox design, you should have it hooked up to an ItemsSource. Don’t have one? I have a tutorial in which I walk through attaching an RSS feed to your control. It was originally written for the ListView, but it will work fine for a ComboBox.
To start out… this is your standard ComboBox:

When working on a comboBox, you have a couple of options for the Items inside the ComboBox. If the options never change and are not data-driven, you can just toss come ComboBoxItems into it. Otherwise, you can connect it to some kind of ItemsSource (see the link above).
All of my examples are done with a data-driven ComboBoxes, but you should get the desired results if you run through the tutorials with ComboBoxItems.
First, a little bit about the structure of the comboBox.
Read the rest of this entry »
February 5th, 2008
Karl Shifflett points to a wonderful life saver of a feature that I didn’t know existed until now.
With Visual Studio 2008, the project is always trying to load the design view with the XAML view. I get very frustrated by this… if I wanted to see the design view, I would open Blend.
Apparently, if you’re in VS2008, you can go to “Tools -> Options…” in the resulting window, open up the “Text” option and scroll down to “XAML -> Miscellaneous” Check the box that says “Always open docuemnts in full XAML view”

Yay.
February 4th, 2008
I’ve been spending the past several days fighting with the ComboBox in an attempt to make it so something very simple: Wrap text inside the combo box. I’ve finally figured it out, so I thought I’d share.
OK, first of all, make sure that your ComboBox is hooked up to something, even if that something is some random RSS feed. I have a post that can help you with that over here. Bind your comboBox to the “Items” part of the New York Times RSS feed.
You need to do this because, if you do not, you will have to set the same data template to every single ComboBoxItem that you add to the ComboBox. And that’s just no fun.
Starting out, your ComboBox should look something like this:

Right click on your ComboBox and select “Edit Other Templates -> Edit Generated Items (ItemTemplate)-> Create Empty…” Give your new data template a name and Blend will take you into the Data Template design.
Read the rest of this entry »
February 2nd, 2008
OK, it’s really late and I want to get this done, so we’re going to go through the easy way, which will require some XAML, but I’ll try to keep it as Blend-y as possible.
So you have a column header and you want the text inside to wrap when the header space gets too short for the content. Your header probably looks something like this:

First, go to wherever your resources are being held and type the following in:
<Style x:Key=”CustomHeaderStyle“ TargetType=”{x:Type GridViewColumnHeader}“>
</Style>
Read the rest of this entry »
February 1st, 2008
(I’m getting to the point in a roundabout way… you can skip directly to the point below if you want.)
When I started working on my WPF-Wii tutorials, my first Wii project was the initial version of the WPF-Wii Visualizer.
However, I quickly got tired of writing the code for handling events and transferring the data from the Wiimote library to my application. So (like any noble geek would do) I wrote even MORE code to solve the problem, not only for myself, but for generations to come.
I’ve spend the last week writing a Wii-To-WPF library that shovels the Wiimote properties into properties that use the INotifyPropertyChanged WPF interface. This will allow anyone to connect to the Wii through the WPF data binding. It’s super cool.
(A point of note, I posted an early version of this library. Ignore it. I’m putting up a much improved version in the next couple days.)
The Point
But I had no idea how moving from a basic data transference and event handling to the INotifyPropertyChanged interface would affect my performance.
Here are some screenshots of Perforator (a WPF performance monitoring application) monitoring my WPF-Wii Visualizer in its code-heavy iteration:

I don’t know what all those numbers mean, but the one I’m interested in is the frame rate. As a designer, smoother motion is good… especially if I’m trying to design a multi-point application. A frame rate of 27 isn’t too bad, but this is the best I got. The frame rate usually hovered around 20, dipping as low as five.
Now… this is what I got when I was binding the data through the XAML (absolutely no code whatsoever):

And this was the worst I got. My frame rate was always in the mid 60s and would spike up to 80. Take note that I’m not changing the interface at all. In fact, I’m running the binding version at a handicap (it’s tracking four infrared points instead of the original two).
Exact same XAML … except that the XAML properties are data bound from within the XAML and not assigned via the C# code.
So, lets take an account of the WPF INotifyPropertyChanged interface:
- Allows DataBinding
- Permits code-light or code-free interface design
- Drastic improvements to performance
Use it!
Enough said.
February 1st, 2008
I recently spent a couple hours trying desperately to bind a TextBlock to the Canvas.Left and Canvas.Top properties for a project I’m working on. My binding looked like this:
{Binding ElementName=MyElement, Path=Canvas.Left, Mode=Default}
Couldn’t do it. I tried bloody everything to get this thing to work, but it wouldn’t do it.
Then I found a post on binding to attached properties (I’ve removed the link since it now points to an attack site. Thank you, Graham), which is apparently what you call a property that is written as
<TextBlock Canvas.Left=”100”
Canvas.Top=”100”
Grid.Column=”1”
Grid.Row=”1”
Grid.ColumnSpan=”1”
Grid.RowSpan=”1“ />
Forgive the redundancy… I’m trying to write this post so that anyone who is having this problem can find the solution.
So the correct binding (the one that works for me, anyway) is:
{Binding (Canvas.Left), ElementName=MyElement}
It works.
Why? I have no idea.
Just passing it along.