VisualStateManager in Silverlight

Last year I've written a german article for the dotnet-magazine about VisualStateManager in Silverlight. As this feature will also be part of WPF 4.0, take a look at the article, which is now available on my homepage. The article is also available on the homepage of Trivadis beside many other articles focused on other IT-Topics. So read and enjoy. :-)
Read more...

The promised code example with the ASP.NET Ajax Multicolumn-Dropdown

During the last months I was asked many times for the code of the Multcolumn-Dropdown that I've described in this post. I've just created a very small sample-application containing such a dropdown. You can download it here. If someone of you creates a control out of that source, I would be glad to get a link to it. :-) Thomas
Read more...

The Lottery-Console-Application used at the last WPF-Event @ Microsoft Usergroup Switzerland

Last week we had a great WPF-afterwork-event at Microsoft Usergroup Switzerland (MSUGS) sponsored by Trivadis. I gave a deep-dive session about developing custom controls using WPF with many of it's features like Dependency Properties, Commands, Routed Events, PART-Elements, Theme-Styles and so on. (more…)
Read more...

Developing Multicolumn-DropDown/DropDownList with ASP.NET, the GridView and the AJAX Control Toolkit

During the last months I was developing an ASP.NET application and I needed a dropdownlist to display multiple columns in each item. Everyone with a little knowledge in Web-development knows, that HTML doesn't contain built-in support for multicolumn-DropDowns. (more…)
Read more...

WPF-book is now available in stores, maybe you win a free one @MSUGS

Since last week my German WPF-book is available in stores. You find more details about the book and some snippets of chapter 1 and chapter 14 on Galileo Computing. You can order the book on the Galileo Comuting-Website or on amazon.de and other stores. For any questions about the book, write a comment to this post or use the contact-form of my homepage. If you've already got the book, I'm looking forward to your feedback. What's going on next: Free MSUGS-Event about developing Custom Controls with the chance to win a WPF-book: On Wednesday, 20th August, you can visit a free event in cooperation with the Microsoft User Group Switzerland (MSUGS) about developing Custom Controls with WPF. The event will be in Zurich @Trivadis (Europastrasse 5). You find more details about the event here. At the end of this event, you can win one WPF-Book for free. WPF-Course @Trivadis: If you want to know more things about WPF-Programming, take a look at the 3-day WPF-course at Trivadis, which you find here. If you take this course, you'll get a WPF-book, the Trivadis course-material, and everything you need to become a rich & famous WPF-Programmer. ;-) DataAccess in the time of LINQ: Christoph Pletz and I are working on a TechnoCircle - a one day event you can visit in the second half of this year @Trivadis - about DataAccess in the time of LINQ. This TechnoCircle does not only show you how LINQ works, it shows how to implement a Data Access Layer in the time of LINQ in a Three-Layer-Architecture. It also discusses the usage of LINQ to SQL vs. Entity Framework vs. DataSets etc. As soon as you can register for the TechnoCircle, you'll find more infos on the Trivadis-website and of course here on my blog...
Read more...

Print of WPF-book will start next week

As I promised in my last post, here are some infos about my nearly finished book project: Last weekend I made checks on the first galley proof of my german WPF-book. Yesterday I got the second galley proof, the corrected one. The second galley proof I've checked yesterday evening and today. The book will have about 1125 pages filled up with pure Windows Presentation Foundation and will be printed at the end of next week. Last week I saw that the book is already listed under the WPF-books on WindowsClient.NET. Who ever linked it up, thanks a lot for doing so:
> http://windowsclient.net/community/books.aspx
As the corrections are made and the book will be printed next week, the upcoming weekend will be the first totally free weekend for me since one year. Two weeks ago I got a red card in a soccer match, so I'm not allowed to play the last game. So next weekend is really totally free, no soccer game and no book-writing. :-) So what should I do this upcoming weekend? I could start writing another WPF- or Silverlight-article. But no, on that first free weekend for such a long time I won't do that. I tell you what I'm going to do, if the weather won't be totally bad: About one month ago I bought a new bike (on the picture below), so I'll test it on a tour with my family next weekend. There are several mountains and single trails directly around our home, where you can jump and ride with a lot of fun. As I know there are also many bikers at Trivadis (the company I'm working for), maybe I'll meet some of them in a race down the hills through the great black forest bikingThomas
Read more...

Got the MCTS: .NET Framework 3.5, Windows Presentation Foundation

Last Thursday I took the exam for the Microsoft Certified Technology Specialist .NET Framework 3.5, Windows Presentation Foundation. The exam is brand new and covers a wide spectrum of WPF. Im not sure, if asking Multiple-choice-questions is a good thing for testing the knowledge of programmers, but hey, the exam was a good test for my German WPF-book. (I didn't have the book with me, but it's still in my head. Like a branding :-)). After every question I read, I thought, if the answer of the question can be found in my book. And I'm really glad to say that, with some exceptions to specific deployment questions, everything can be found in my book. So if you know all contents and details of my book well, you won't have any problems to pass this exam. So with the book still in my head I did it and earned my fourth MCTS:  MCTS_Logo By the way, I've finished the manuscript for my wpf book in time. Since end of April the correctors give their best and I'm sure the book will be in stores in June 2008, according to plan. Find more infos about the book-process during the next weeks on this blog.
Read more...

WPF Multi-Layer Business Application for Download

Tomorrow Karl Shifflett is giving a Code Camp session in Charlotte. Unfortunately it's too far away for me to participate. :-) Today Karl has posted a really great WPF Multi-Layer Business Application that can be downloaded from his blog. Check it out here and learn from it. Thx to Karl for posting and sharing that great sample app.
Read more...

LostFocus (TextBox) vs. Buttons IsDefault-Property

If you bind the Text-Property of a TextBox to something, the "something" is updated when the TextBox loses focus. This is the Default-UpdateSourceTrigger defined in the Metadata for the TextBox.TextProperty. In a Data Binding you can specify another UpdateSourceTrigger, like e.g. PropertyChanged. If a TextBox has LostFocus as UpdateSourceTrigger, which is the default, you can get problems if the TextBox is inside of a Dialog that contains a OK-Button with the IsDefault-Property set to true. When the TextBox has the Focus, the user can press Enter and the Button is clicked, but the TextBox still keeps the Focus. The LostFocus-Event doesn't occur, so the Source of a Data Binding isn't updated with the value of the TextBoxs Text-Property. You need to update the source explicit. Let's take an example and use the Person-class of my previous post:
public class Person : INotifyPropertyChanged
{
  private string _name;
  public string Name
  {
    get { return _name; }
    set
    {
      _name = value;
      if (PropertyChanged != null)
        PropertyChanged(this,
          new PropertyChangedEventArgs("Name"));
    }
  }
  public event PropertyChangedEventHandler PropertyChanged;
}
The Window below just contains a TextBox and a Button. The Text-Property of the TextBox is bound to the Name of the data in the DataContext. This would be a Person-instance, as you'll see below in the codebehind-file. The Button has it's IsDefault-Property set to true and defines an eventhandler for the Click-Event.
<Window x:Class="LostFocusTest.Window1" ...
  xmlns:local="clr-namespace:LostFocusTest"
  Title="Focus/IsDefault" Width="200" SizeToContent="Height">
  <StackPanel>
    <TextBox Margin="5" Text="{Binding Name}"/>
    <Button Content="OK" IsDefault="True"
       Click="Button_Click"/>
  </StackPanel>
</Window>
In the Constructor in the Codebehind-file a Person-instance is created. It's assigned to the Windows DataContext-Property, so the TextBox above will display the Persons name, which is set to "Thomas". The Click-Eventhandler for the Button simply displays the name of the Person in a MessageBox.
public partial class Window1 : Window
{
  private Person _pers;
  public Window1()
  {
    InitializeComponent();
    _pers = new Person();
    _pers.Name = "Thomas";
    this.DataContext = _pers;
  }

  private void Button_Click(object sender, RoutedEventArgs e)
  {
    MessageBox.Show(_pers.Name);
  }
}
If I start the application and type "Urs" into the TextBox and press Enter, the Button is clicked but the TextBox keeps the focus. So the Source, which is the Person-Instance, isn't updated and the MessageBox still displays the old value ("Thomas"), as you can see in the Image below: LostFocus vs. IsDefault For such a scenario, you have to update the source explicit. You could do this in the Click-Eventhandler. To update the source, you have to get the BindingExpression for the TextProperty. You get the BindingExpression by calling the GetBindingExpression-Method on the TextBox. Pass in the Text-Property as parameter. On the BindingExpression call the UpdateSource-Method to update the Person-instance explicitly with the value defined in the Text-Property of the TextBox. With the Eventhandler below the Person-Instance would always be actualized when the Button is clicked. The MessageBox would display the right value:
private void Button_Click(object sender, RoutedEventArgs e)
{
  TextBox textBox = Keyboard.FocusedElement as TextBox;
  if (textBox != null)
  {
    BindingExpression be =
      textBox.GetBindingExpression(TextBox.TextProperty);
    if (be != null)
      be.UpdateSource();
  }
  MessageBox.Show(_pers.Name);
}
Just kick it for me: kick it on DotNetKicks.com
Read more...