.NET Framework

Windows Store-apps with XAML and C# – blog series

Since yesterday evening Winodws 8 RTM is out for developers. This blogpost is the start of a blog-series about developing Windows Store-apps with XAML and C#. The series consists of some informational and some “how-to” posts: More topics will come. If you’ve topics not listed above you want to read about, write a comment on this post. The first post about XAML will be written till saturday evening Thomas
Read more...

TechDays 2011 – Demos online

Thanks to all who attended in my session at TechDays 2011 in Basel. My Live-Demo is available via the link below. TechDays Basel - LiveDemo - Download here The .zip-File contains a .bak-File that you can restore via SQL Server Management Studio by chosing “Restore Database” from the contextmenu when right-clicking on “databases” in Object Explorer.
Read more...

Speaking at GUI & Design Conference in Nürnberg

It has been quiet here for some weeks. After I had finished my Silverlight book I just enjoyed the unfamiliar free time I had on Saturday and Sunday. I just used it for hanging around with my family and friends. Now I’m back in the optimum of work-life-balance. I’m going to start a series of blogposts about building apps with Silverlight for the Web and for Windows Phone 7 in the mid of december. So I hope you’re looking forward to that. With this post I want to inform you about the GUI&Design-Conference. The conference about GUI and Design has a lot of experts and great sessions to offer. I think it’s a special and great conference that you shouldn’t miss as a UI-Developer or –Designer. It would be great to see you there. I’ve two sessions. One about Pixelshader-Effects in WPF and Silverlight and one about developing and designing Custom Controls in WPF and Silverlight. Find the conference-website on http://www.gui-design.ppedv.de/ or just click on the image below to join it. fullsize_468x60_1-4 Looking forward to see you there. Thomas
Read more...

From Visual Studio 2010 Release Candidate back to Beta 2

If you’ve played around with Visual Studio 2010 Release Candidate (RC), you sure have noticed that it’s pretty fast. E.g. the WPF- and Silverlight-Designers come up quickly and much faster that in Visual Studio 2008. But for now there are some reasons to wait before installing Visual Studio 2010 RC:
  • Silverlight 4 Beta is not supported. Silverlight 4 will be supported with the next public drop of Silverlight 4, what means when the Silverlight 4 RC is available. A date for that hasn’t been specified yet by Microsoft.
  • The available Preview Version for .NET 4.0 of Expression Blend doesn’t work with Visual Studio 2010 RC. It only works with Beta 2 of Visual Studio 2010. A new version will be available soon as the Expression Website says, but no one knows what "soon" means.
The second point I just noticed now. And so I decided to go back to Beta 2 cause I’ve a session about Model-View-ViewModel this week at BASTA! Spring in Darmstadt. To go back to Beta 2, make sure you uninstall everything of the Release Candidate. After I’ve uninstalled Visual Studio 2010 RC, I had additionally to remove .NET Framework 4.0 from Programs in Control Panel. Tip: Order the installed programs by date, then you see what you’ve to uninstall pretty good. After I’ve installed the Beta 2 again, everything worked fine. But I got an error when compiling my WPF-project telling me the following: "GenerateResource" task failed unexpectedly. System.DllNotFoundException: Unable to load DLL 'FileTracker.dll' …” After some search I found a connect-entry on microsoft.com with the solution. My folder "C:\Windows\Microsoft.NET\Framework” contained a “v4.0” directory additionally to the "v4.0.21006" directory installed with Visual Studio 2010 Beta 2. After deleting the additional folder that has a higher number than v4.0.21006 (it’s the RC ;-)), the Beta 2 works fine again and I can compile everything as expected. Find the connect-entry that pointed me to the solution here:  https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=501894&wa=wsignin1.0
Read more...

Speaking at BASTA! Spring about WPF 4.0 and MVVM

The BASTA! (=Basic Days => in German Basis Tage) is “the” Conference in Germany about .NET. The BASTA! Spring is from 22nd to 26th February. basta10s_button_speaker_en I’ve two sessions there: one Wednesday (24. February) and one on Thursday (25th February). I’ll talk about the new features in WPF 4.0 and about the Model-View-ViewModel-Pattern (MVVM). Find more (German) infos about my sessions on http://www.thomasclaudiushuber.com/talks.php. Also look at the conference-homepage www.basta.net, there are many great sessions. Looking forward to see you there and talking with you about Windows Presentation Foundation, Silverlight and your upcoming projects.
Read more...

The DataGrid and the “Input string is not in a correct format” message in Silverlight

If you play around with the DataGrid in Silverlight and try some scenarios, maybe you come around the FormatException with the Message “Input String is not in a correct format”. You get this Exception if your Data-Object e.g. has a Property of type int and the user enters some characters in the DataGrid. The Exception doesn’t come up, instead the DataGrid shows it as a validation error. Let’s look at an example. Image you’ve a very simple Person-class containing a FirstName-Property of type string and an Age-Property of type int:
public class Person : INotifyPropertyChanged
{
  private int? _age;
  private string _firstName;
  public string FirstName
  {
    get { return _firstName; }
    set
    {
      _firstName = value;
      Changed("FirstName");
    }
  }

  public int? Age
  {
    get { return _age; }
    set
    {
      _age = value;
      Changed("Age");
    }
  }

  private void Changed(string propertyName)
  {
    if (PropertyChanged != null)
      PropertyChanged(this, 
        new PropertyChangedEventArgs(propertyName));
  }

  public event PropertyChangedEventHandler PropertyChanged;
}
Now let’s fill up a List with some Test-Persons and add that list to the DataContext of your page:
public MainPage()
{
  InitializeComponent();
  this.DataContext = new List { 
    new Person{ FirstName="Thomas",Age=29},
    new Person{ FirstName="Julia",Age=27},
    new Person{ FirstName="Ben",Age=1},
  };
}
No in the XAML-File of your MainPage a DataGrid could be defined like below. Notice the ItemsSource-Property that is bound to the DataContext:
<my:DataGrid ItemsSource="{Binding}"
             AutoGenerateColumns="False">     
  <my:DataGrid.Columns>
    <my:DataGridTextColumn Header="FirstName"
                           Binding="{Binding FirstName}"/>
    <my:DataGridTextColumn Header="Age"
                           Binding="{Binding Age}"/>
  </my:DataGrid.Columns>
</my:DataGrid>
When the User now enters a string as Age, the FormatException is raised before the Property is updated and the Message of the FormatException is displayed in the DataGrid: image Now the question is, where to change this string. The DataGrid has a BindingValidationError-Event, but there you have only read access to the FormatException and the Errormessage. In the Property itself you can’t do anything, because the Exception is thrown before the Age-Property is set. The solution is to define a Property special for Display in the Person-class. Normally you would create a ViewModel that encapsulates the Person-class and contains the additional property. In my case I implement the Property directly in the Person-class. I call it AgeDisplay-Property. Inside that property you can then throw your own FormatException with your special text. My Person-class now looks like this:
public class Person : INotifyPropertyChanged
{
  private int? _age;
  private string _firstName;
  public string FirstName
  {
    get { return _firstName; }
    set
    {
      _firstName = value;
      Changed("FirstName");
    }
  }

  public int? Age
  {
    get { return _age; }
    set
    {
      _age = value;
      Changed("Age");
      Changed("AgeDisplay");
    }
  }


  public string AgeDisplay
  {
    get { return Age.ToString(); ; }
    set
    {
      if (value == null)
      {
        Age = null;
        return;
      }
      int result;
      if (int.TryParse(value, out result))
      {
        Age = result;
      }
      else
      {
        throw new FormatException("Age must be a number. "
                        + " Characters are not allowed.");
      }
    }
  }

  private void Changed(string propertyName)
  {
    if (PropertyChanged != null)
      PropertyChanged(this, 
        new PropertyChangedEventArgs(propertyName));
  }

  public event PropertyChangedEventHandler PropertyChanged;
}
Now you simple bind the DataGrid’s Column to AgeDisplay instead of Age:
<my:DataGrid ItemsSource="{Binding}"
             AutoGenerateColumns="False">     
  <my:DataGrid.Columns>
    <my:DataGridTextColumn Header="FirstName"
                           Binding="{Binding FirstName}"/>
    <my:DataGridTextColumn Header="Age"
                           Binding="{Binding AgeDisplay}"/>
  </my:DataGrid.Columns>
</my:DataGrid>
When the user now enters a string into the Age-Column, the text of the FormatException thrown in the AgeDisplay-Property is displayed: image
Read more...

How-to deploy the Crystal Reports Basic Runtime that’s included in Visual Studio 2008

This week I've to deploy an ASP.NET application containing about 20 reports that have been created with the Crystal Reports Basic Runtime which is included in Visual Studio 2008. (By the way, the application also contains a lot of AJAX-Functionality. It uses the "AJAX Control Toolkit-based" MultiColumnDropDown that I've described in a previous post). When deploying the application to a different machine than your developer-machine, the Crystal Report Basic Runtime must be deployed also. You do that by copying the necessary msi-file to the server and run it. The "necessary" .msi-file is already on your development machine and were installed with Visual Studio 2008. The .msi-files for different plattforms are located in the following paths:
Runtime | MSI-Location
(x86) C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5\CRRedist2008_x86.msi
(x64) C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5\CRRedist2008_x64.msi
(IA64) C:\Program Files\Microsoft Visual Studio 9.0\Crystal Reports\CRRedist\IA64\CRRedist2008_ia64.msi
(the table above is contained in MSDN-documentation here) The installation is very simple. You doesn't need to click anything, simply run the .msi and you see the window below. Just wait until it closes. crystalReportsBasic There's also the possibility to include the msi in your setup-application. For more information on that take a look at this thread in MSDN-Forums.
Read more...