Howto show the resize grip (window drag handle)

If you want to display the the drag handle in the lower right corner of the Window you have to set the ResizeMode Window property like that:

Code Snippet
  1. <Window
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. ResizeMode="CanResizeWithGrip">

This is the result:

resizegrip

Outputdebugstring in .NET / Visual Studio / C# / WPF

In my old Delphi developer days I used OutputDebugString() to track problems or elapsed time.
In .NET you can use the System.Diagnostics.Debug class.

You have to run the project in debug mode.

Code Snippet
  1. private void ReadFirstFile(string filename1)
  2. {
  3.     StatusText = "Reading file 1";
  4.     Stopwatch watch = new Stopwatch();
  5.     watch.Start();
  6.     using (StreamReader file1 = new StreamReader(filename1))
  7.     {
  8.         while (!file1.EndOfStream)
  9.         {
  10.             sc1.Add(file1.ReadLine());
  11.         }
  12.     }
  13.     watch.Stop();
  14.     System.Diagnostics.Debug.WriteLine("Time spent reading file 1: " + watch.Elapsed);
  15. }

MSDN link: http://msdn.microsoft.com/en-us/library/6x31ezs1.aspx

Ressource “mainwindow.xaml” could not be found

If you got error message “Die Ressource “mainwindow.xaml” kann nicht gefunden werden.” or “Ressource “mainwindow.xaml” could not be found” compiling your project your MainWindow.xaml maybe moved to a subfolder. You have to adopt the path to the MainWindow.xaml in yor App.xaml.

<Application x:Class="Your.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="Views/MainWindow.xaml">
    <Application.Resources>

    </Application.Resources>
</Application>

Fehlermeldung “kann nicht mit einem Instanzenverweis zugegriffen werden. Qualifizieren Sie ihn stattdessen mit einem Typnamen.”

Diese Meldung haut Ihnen der Compiler um die Ohren wenn Sie versuchen auf eine Instanz anstatt direkt auf den Typen bzw. class zuzugreifen.

 

Ein Beispiel:

public class MyClass

{

          public static string MyConst = “My test const”;

}

 

Erzeugen einer Instanz:

MyClass _myclass= new MyClass();

 

Falscher Zugriffsversuch:

MessageBox(_myclass.MyConst);

 

Richtiger Zugriffsversuch:

MessageBox(MyClass.MyConst);