Archive for the ‘.NET’ Category

Microsoft TechDays 2013 Basel

Friday, November 15th, 2013

Thanks to all who joined my sessions at TechDays in Basel. Also a big thanks to Microsoft Switzerland for organizing this great and successful event. I really enjoyed the two days of networking with awesome people.

Please find the slides and demos of my talks on my homepage by selecting the talk:

http://www.thomasclaudiushuber.com/talks.php

If you were not able to attend TechDays in Basel, you can just watch my talks here (they’re in German. Find other talks on on channel9):

 

Feel free to ask any questions about the topics by commenting here or just send me an email.

Thomas

Received Microsoft MVP award 2013

Saturday, July 6th, 2013

Wow, on 1st of July I’ve received my very first Microsoft MVP (Most Valuable Professional) award. I received it in the area “Client Development”.

MVP_FullColor_ForScreen

Thanks to all the people out there in the .NET/C#/XAML-community, thanks to all the readers of my books, articles and blog-posts, thanks to the participants of my public talks, thanks to the colleagues at Trivadis and thanks to Microsoft Switzerland for their great support. In the end I want to thank my family and all the friends and people supporting me in any technical and non-technical way. You’re awesome!

More about the MVP award you can read on
http://mvp.microsoft.com/

My personal MVP profile is here:
http://mvp.microsoft.com/en-us/mvp/Thomas%20Claudius%20Huber-5000162

Keep on codin’
Thomas

Dragging Elements in Windows Store Apps

Wednesday, December 12th, 2012

In Windows Store Apps there are three kinds of Touch-Events:

  • Gesture Events – those are high-level-events like Tapped or RightTapped.
  • Pointer-Events – low-level-events like PointerPressed, PointerMoved, PointerReleased.
  • Manipulation-Events – low-level-events for multi-touch actions like rotate, scale or transform an element.

Pointer-Events consolidate Touch-, Pen- and Mouse-Input. So on the UIElement-class from WinRT you wont find Mouse-Events known from WPF/Silverlight like MouseLeftButtonDown.

In my upcoming Windows Store Apps I want to show how Elements can be dragged/moved with Pointer-Events. You can download the code of the sample here:

MovingElements, or in German ElementeVerschieben-Sample

The app looks like below. By touching an empty space in the yellow area, an Image is inserted. The image can be grabbed with a finger or with the mouse-cursor and moved around. The app works also with multiple fingers. You can grab multiple images at once and move them around.

MovingElementsWinRT

If you´ve feedback to the code, feel free to comment. Smiley 

As I´m really busy the next weeks/months with the writing of the Windows Store Apps-book, I´m not able to give you big support on the code. Use it or not.

Thomas

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

Thursday, August 16th, 2012

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

TechDays 2011 – Demos online

Wednesday, May 4th, 2011

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.

Speaking at GUI & Design Conference in Nürnberg

Wednesday, November 24th, 2010

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

BASTA! Conference – WPF 4.0 Session

Tuesday, September 21st, 2010

Hallo liebe Teilnehmer der WPF 4.0-Session. Anbei finden Sie die Links zu den Slides und zu den live programmierten Demos des Vortrags. Viel Spass damit und bis morgen zur Silverlight 4.0 Session.

Slides und Demos

image

From Visual Studio 2010 Release Candidate back to Beta 2

Monday, February 22nd, 2010

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

Speaking at BASTA! Spring about WPF 4.0 and MVVM

Sunday, January 24th, 2010

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.

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

Sunday, December 20th, 2009

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<Person> { 
    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;
}

No 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