Rubens Blog
Using Windows Presentation Foundation for Good and Not Evil 
Thursday, October 16, 2008, 08:44 PM
Posted by Ruben Steins
If you haven't watched Using Windows Presentation Foundation for Good and Not Evil by David Platt, you probably should. I have seen this talk at the DevDays 2008 in July in Amsterdm and it was pretty good. Of course Platt likes to put things in a less-than-roundabout way, but overall he's got some pretty good points to make about WPF.
Pretty much it boils down to the first law of Spiderman: "With great power comes great responsibility". So take care not to create
 <BLINK></BLINK> 

tags in your application (or their WPF equivalents)!

Addition: you should also read Why Software Sucks which is a nice rant about the grief we as developers cause our users. It's insightful and witty as well!
add comment   |  permalink   |  related link   |   ( 3 / 17 )
Spotlight: The WPF TextBox 
Wednesday, October 15, 2008, 02:30 PM
Posted by Ruben Steins
'Spotlights' are something new for me. I'm going to try and focus on a single WPF control once a week and make an extensive post about it.

The WPF TextBox


It seems a bit silly to talk about such a simple and basic control as the WPF TextBox. After all, we see these things all the time. You add them to you favorite container and they show editable text, or according to the MSDN Documentation:
[TextBox] represents a control that can be used to display or edit unformatted text.





Usage is simple:

<Grid>
<TextBox x:Name="MyTextBox">Hello World</TextBox>
</Grid>

You can also add color and font information to fit it into your look-and-feel:

<Grid>
<TextBox x:Name="MyTextBox" Background="LightGray"
Foreground="DarkBlue" FontFamily="Calibri"
FontSize="12" FontWeight="Bold">
Fancy Hello World
</TextBox>
</Grid>

But, there might be some interesting things you might not know about the TextBox.

Undo functionality


TextBox supports Undo-functinality out-of-the-box. You can simply call Undo() from code and the latest change to the text gets reverted. In fact, by default the UndoLimit property (inherited from TextBoxBase) is set to -1, which means 'infinite undo'. In practice this means there is a potential memoryleak there, since the undo-stack will keep on expanding as long as there's memory available in your system (read a nice solution that will prevent this from happening automagically)

Spell-checking


Textbox support spell-checking as well, out-of-the-box.
<TextBox SpellCheck.IsEnabled="True" />

The code above is enough to make this feature work. Currently it's not possible to specify a custom dictionary but still, so you have to have Office 2003 or higher installed (I think) to make it work properly. Look at this Spelling Suggestions in a WPF TextBox for some additional information and a nice implementation.

Support for Copy-Cut-Paste


Some WPF controls have a couple of commands associated with them by default. TextBox is one of them and supports Copy, Cut and Paste (and Undo and Redo as well).

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/
presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Orientation="Horizontal" Height="25">
<Button Command="Cut" CommandTarget=
"{Binding ElementName=textBox}"
Content="{Binding RelativeSource={RelativeSource Self},
Path=Command.Text}"/>
<Button Command="Copy" CommandTarget=
"{Binding ElementName=textBox}"
Content="{Binding RelativeSource={RelativeSource Self},
Path=Command.Text}"/>
<Button Command="Paste" CommandTarget=
"{Binding ElementName=textBox}"
Content="{Binding RelativeSource={RelativeSource Self},
Path=Command.Text}"/>
<Button Command="Undo" CommandTarget=
"{Binding ElementName=textBox}"
Content="{Binding RelativeSource={RelativeSource Self},
Path=Command.Text}"/>
<Button Command="Redo" CommandTarget=
"{Binding ElementName=textBox}"
Content="{Binding RelativeSource={RelativeSource Self},
Path=Command.Text}"/>
<TextBox x:Name="textBox" Width="200"/>
</StackPanel>

This examples is taken from a sample chapter for Adam Nathans 'WPF Unleashed' which is an awesome book. It shows how simple it is to create a fully functional Cut/Copy/Paste textbox. The best thing about it the fact that the buttons enable or disable based on whether or not there is text on the clipboard. You automatically get CanExecute() methods.

So, these are a couple of intersting tid-bits about the WPF TextBox. I'll list some more in a follow-up post since I'm a bit short on time right now!

add comment   |  permalink   |  related link   |   ( 2.9 / 123 )
Silverlight 2 Has been released 
Tuesday, October 14, 2008, 01:00 PM
Posted by Ruben Steins
In case you've missed it (as I had) the new version of Silverlight has been released!

Cool! Read Tim Heuers extensive post about what you need to get started quickly with SL2!

Update
Usually the first to post, Scott Guthrie waited a bit but finally posted about Silverlight 2. As we've come to know from Scott, his post is another gem, giving a great overview of the SL2 features and links to his updated series on creating a Digg-client with Silverlight 2. Awesome!
add comment   |  permalink   |  related link   |   ( 2.9 / 28 )
A 3D screensaver written in WPF 
Monday, October 13, 2008, 01:16 PM
Posted by Ruben Steins
It really amazes me what Sasha Barber can do when he has to
wait in ... for a new washing machine to be delivered, so had a few hours to spare. So decided it might be fun to try and create a nice WPF screen saver. This article is the outcome of this.

Sasha sites down and writes a 3D Screensaver in WPF like it's nothing... It's pretty useless, but a heck of a lot of fun!
add comment   |  permalink   |  related link   |   ( 2.8 / 13 )
Custom Controls – The Dénoue... err what? 
Friday, October 10, 2008, 01:54 PM
Posted by Ruben Steins
Another great post by Jesse Libery. He's been showing us how to create custom controls in Silverlight, he's explained the Silverlight Dependency Properties (which now closely resemble WPF Dependency Properties) and now he's going to dig into how the control conveys its visual contract to the Visual State Manager. The VSM provides an easy way to skin your controls because you simply define a couple of states and specify how your control looks in each of those.

According to Jesse himself he's not going to elaborate any further, we'll just have to wait for his level 300-400 video-tutorials...
I have to confess, this is what I really like about custom controls; the closer you look, the more there is to see. That said, I think we've gone about as far as we can without exploring this in a video, so I'll turn my attention in coming blog posts to some other emerging features.

add comment   |  permalink   |  related link   |   ( 2.9 / 12 )

<<First <Back | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Next> Last>>