Syntax Error

Code samples and hints

MessageBox for WinRT

Simple Messagebox ....
public async void ShowMessage(string message)
   MessageDialog msg= new MessageDialog(message);
   await msg.ShowAsync();
A more complex example from Corrado's BLogs  
private  async void OnMessage(object sender, RoutedEventArgs e)
   MessageDialog dialog = new MessageDialog("Hello WinRT");
   UICommandInvokedHandler cmdHandler = new UICommandInvokedHandler(cmd =>
      Debug.WriteLine("id:{0} label:{1}", cmd.Id, cmd.Label);

   UICommand cmd1 = new UICommand("Cmd1", cmdHandler, 1);
   UICommand cmd2 = new UICommand("Cmd2", cmdHandler, 2);
   UICommand cmd3 = new UICommand("Cmd3", (cmd) =>
      Debug.WriteLine("Command3 done!");
   }, 3);

   dialog.DefaultCommandIndex = 1;

   await dialog.ShowAsync();
   Debug.WriteLine("Dialog closed");

Free WYSIWYG rich text editor including printing, print preview and full table support for Visual Studio

TX Text Control Express - free, professional rich text editing

Upgrade your Microsoft Visual Studio toolbox with a true WYSIWYG rich text editor including printing, print preview and full table support.

Available for Windows Forms, TX Text Control Express is the free edition of TX Text Control - the market leading word processing component.

  • Integrate a professional WYSIWYG rich text editor into your applications.
  • Replace the standard .NET Framework RichTextBox.
  • Add ready-to-use toolbars and dialogs out of the box.
  • Load, save and print RTF and HTML documents.
  • Developed in sync with the Professional and Enterprise editions.
  • Completely free of charge (no royalties, no expiry date).

Scrollable TextBox for Windows Phone

The TextBox control does not support scrolling in the non-edit mode.

If needed, there is the simple way:

Or you can create your own ControlTemplate and do something like this:


<ControlTemplate x:Key="ScrollableTextBox" TargetType="TextBox">
	<Grid Background="Transparent">
			<VisualStateGroup x:Name="FocusStates">
				<VisualState x:Name="Focused">
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EnabledBorderScroll" Storyboard.TargetProperty="VerticalScrollBarVisibility">
							<DiscreteObjectKeyFrame KeyTime="0">
		<Border x:Name="EnabledBorder" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Margin="{StaticResource PhoneTouchTargetOverhang}">
			<ScrollViewer x:Name="EnabledBorderScroll" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
				<ContentControl x:Name="ContentElement" BorderThickness="0" Padding="{TemplateBinding Padding}" 
				HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}"/>
		<Border x:Name="DisabledOrReadonlyBorder" Visibility="Collapsed" Background="Transparent" BorderBrush="{StaticResource PhoneDisabledBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="{StaticResource PhoneTouchTargetOverhang}" >
			<TextBox x:Name="DisabledOrReadonlyContent" Text="{TemplateBinding Text}" Foreground="{StaticResource PhoneDisabledBrush}" Background="Transparent"
				SelectionBackground="{TemplateBinding SelectionBackground}" SelectionForeground="{TemplateBinding SelectionForeground}"
				TextWrapping="{TemplateBinding TextWrapping}" TextAlignment="{TemplateBinding TextAlignment}" IsReadOnly="True" Template="{StaticResource PhoneDisabledTextBoxTemplate}"
				FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" />

Mouse without Borders

Mouse Without Borders is a project I’ve been familiar with for the last 6 months or so and it’s a wonderfully useful tool. In a nutshell, it allows you to reach across your PC's as if they were part of one single desktop. I have two PCs on my desk at work connected to 3 LCD screens and using Mouse Without Borders I can move my mouse between the 3 screens, even though one of them is attached to a different PC from the other two. What’s more, I can move files between the 2 computers simply by dragging them from one desktop to another. In fact you can control up to four computers from a single mouse and keyboard with no extra hardware needed – it’s all software magic, developed by Truong Do who by day is a developed for Microsoft Dynamics. The software is easy to setup and in addition to enabling drag and drop of files, you can lock or log in to all PCs from one PC, and as a whimsical bonus is it allows you to customize your Windows logo screen with the daily image from Bing or a local collection of pictures :) I regularly use it to have one PC dedicated to social media streams while I work away on my other PC connected to two screens.

Read the full blog at



‘Cannot register duplicate name ‘XXX’ in this scope’ in VS 2010

If you have the problem, that Visual Studio 2010 complains ‘Cannot register duplicate name ‘XXX’ in this scope’, check if you have Resources with a x:Name insted of x:Key-Name:

<SolidColorBrush x:Name="NonWorkingResourceName" Color="Red" />
<SolidColorBrush x:Key="WorkingResourceName" Color="Blue" />

Replace x:Name with x:Key and everything is ok.

Read the full post here ...

Caliburn.Micro – Introduction

Caliburn.Micro – Introduction

Caliburn.Micro is a lightweight and small, yet powerful framework for developing rich WPF, Silverlight or Windows Phone applications. Caliburn.Micro has only a single dependency to the System.Windows.Interactivity library. Due to its small footprint of only 75 k and approximately 2700 lines of code it is not only lightning fast in startup and execution time but also easy to understand. The framework offers pattern guidance for the following well established design patterns:

  • Model – View – ViewModel (MVVM)
  • Model – View – Presenter (MVP)
  • Model – View – Controller (MVC)

Rob Eisenberg ( and Marco Amendola ( are actively maintaining the project and taking care of the documentation. The documentation is really thorough and offers tips and tricks how to avoid the common pitfalls. The project is released under a developer and company friendly license namely the MIT License.

Change Database-Table Collations

To change the Database Table Collations dynamically, you can generate update scripts with the following snippet

declare  @toCollation sysname 
SET    @toCollation = 'Latin1_General_100_CI_AS' --  << insert your destination collation name

       '   ALTER COLUMN ' + COLUMN_NAME + ' ' + DATA_TYPE +
            WHEN DATA_TYPE in ('text','ntext') then ''
       +' COLLATE ' + @toCollation+ ' ' + CASE IS_NULLABLE
                                           WHEN 'YES' THEN 'NULL'
                                           WHEN 'No' THEN 'NOT NULL' 

WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar','text','ntext')
and COLLATION_NAME <> @toCollation

Solution: It takes much longer to run a stored procedure than run the code inside the stored procedure

If you have the problem that a stored procedure takes much longer to execute than the exactly same code direct on the MS SQL Server Management Studio, consider the possibility of side-effects from "Parameter Sniffing".
CREATE Procedure [dbo].[SlowExcecution]
@MyParam NVARCHAR(50)

If this code runs fast without SP, but slow as SP, then add a new local variable and copy the parameter into this variable. Then use this variable instead of the parameter.
CREATE Procedure [dbo].[FastExcecution]
@MyParam NVARCHAR(50)

DECLARE @MyLocalVariable NVARCHAR(50)
@MyLocalVariable = @MyParam

SELECT * FROM XYZ WHERE A = @MyLocalVariable
For details and background informations take a look at this great blog ....