Syntax Error

Code samples and hints

Disable the scroll functionality on the GridView

A GridView within a ScrollViewer results in unwanted mouse wheel behaviour. 

Disable the scroll functionality on the GridView:

<ControlTemplate x:Key="GridViewWithoutScrolling" TargetType="GridView">
        <Border BorderBrush="{TemplateBinding BorderBrush}"
        		Background="{TemplateBinding Background}"
        		BorderThickness="{TemplateBinding BorderThickness}">
            <ItemsPresenter
        				Header="{TemplateBinding Header}" 
        				HeaderTemplate="{TemplateBinding HeaderTemplate}"
        				HeaderTransitions="{TemplateBinding HeaderTransitions}"
        				Padding="{TemplateBinding Padding}"/>
        </Border>
    </ControlTemplate>

Werden Sie Meister Ihres Faches: Stufe 1 (Visual Studio 2012)

Mit der Entwicklungsplattform Visual Studio 2012 stellt Microsoft eine ganzheitliche und integrierte Application Life Cycle Management (ALM) Lösung für die Softwareentwicklung zur Verfügung. Visual Studio 2012 unterstützt im gesamten Entwicklungsprozess mit professionellen Werkzeugen.

Wir von bbv Software Services haben gemeinsam mit Microsoft und weiteren Microsoft-Partnern ein mehrstufiges Training zu Visual Studio 2012 zusammengestellt. Mit diesem Training kannst du dein Wissen zu Visual Studio vertiefen und neue Lösungen kennen lernen.

 

Behandelte Themen:
-  ApplicationLife Cycle Management
-  Team FoundationServer/Service Überblick
-  Windows Store Apps
-  Windows Azure WebSites
-  Windows Azure Mobile Services
-  Web-Entwicklung (SignalR)

 

Die Folien und der Source Code der Demo Applikation sind nun online:
FY13 Devtools Campaign - Training Stufe 1 bbv Master.pdf (2.40 mb)
Source.rar (23 mb)

How to keep the display on during audio/video playback

How to keep the display on during audio/video playback

 

// Create this variable at a global scope. Set it to null.
private DisplayRequest dispRequest = null;

public void StartVideoPlayback()
{
    if (dispRequest == null) 
    {
        
        // Activate a display-required request. If successful, the screen is 
        // guaranteed not to turn off automatically due to user inactivity.
        dispRequest = new DisplayRequest();
        dispRequest.RequestActive();
        
        rootPage.NotifyUser("Display request activated",
                        NotifyType.StatusMessage);
        
        
        // Insert your own code here to start the video.
        
    }
}

public void StopVideoPlayback()
{
    // Insert your own code here to stop the video.
    
    if (dispRequest != null)
    {
        
        // Deactivate the display request and set the var to null.
        dispRequest.RequestRelease();
        dispRequest = null;
        
        rootPage.NotifyUser("Display request released",
                            NotifyType.StatusMessage);
        
    }
}

Quelle

Windows 8: Windows Store Apps-Booklet (Kostenlos)

Dieses Booklet beschäftigt sich mit den Grundlagen von Windows Store Applikationen, die mit dem neuen Microsoft-Betriebssystem Windows 8 und dem damit verbundenen Windows Store eingeführt wurden. Bis kurz vor der Windows-8-Markteinführung waren diese Applikationen unter dem Namen Windows Metro Style Apps bekannt.

Windows_8_Windows_Store_Apps.pdf (2.2 MB)

 

1. Übersicht
2. Ausblick auf Windows 8
  2.1 Windows im Zeitraffer
  2.2 Windows 8 Features
  2.3 Windows Store Apps
3. Softwareentwicklung für Windows 8
  3.1 Windows Store Applikationen
  3.2 Desktop Apps
4. Grundlagen für Windows Store Apps
  4.1 Lebenszyklus einer Windows Store App
  4.2 Datenhaltung und Einstellungen
    4.2.1 Applikationsdaten
    4.2.2 Vordefinierte Speicherorte 
    4.2.3 Freie Speicherorte
    4.2.4 Web/Cloud
  4.3 Leben in der Sandbox
  4.4 Ausrichtung, Grösse und Struktur
  4.5 Elemente einer Windows Store App
    4.5.1 App-Leiste
    4.5.2 Navigationsleiste
    4.5.3 Charms-Leiste
    4.5.4 Suchen, Teilen, Einstellungen
  4.6 Kacheln und Benachrichtigungen
    4.6.1 Kacheln
    4.6.2 Toast-Benachrichtigungen
5. Prinzipien einer Windows Store Applikation
  5.1 Weniger ist mehr
  5.2 Schnell & dynamisch
  5.3 Digital authentisch
  5.4 Gemeinsam
6. Windows Store
  6.1 Drehscheibe für Apps und Einnahmen
  6.2 Marktabdeckung
  6.3 Windows Store Apps im Store veröffentlichen
  6.4 Preismodelle
  6.5 Line-of-business Apps
7. Ausblick
  7.1 Neues Segment, neue Möglichkeiten
    7.1.1 Präsentation und einfache Eingabe-Szenarien
    7.1.2 Spiele
    7.1.3 Side-by-Side
  7.2 Einstieg in die Entwicklung
8. Anhang
  8.1 Autor
  8.2 Kontakt

Quelle & alle weiteren Booklets der Firma bbv Software Services AG 

 

Time limit on suspending a WinRT app

When a WinRT Metro Style app gets suspended, you have to save your user state for the case that the app will be terminated later. 

You have a maximum time limit of 5 seconds to finish your work. After this time the app is closed without any further actions.
First tell the system, that you want to do something with the SuspendingOperation GetDeferral-Method. After your save actions, finish your work with Complete.

/// <summary>
/// Invoked when application execution is being suspended.  Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
async void OnSuspending(object sender, SuspendingEventArgs e)
{
            var waitState = e.SuspendingOperation.GetDeferral();

            Debug.WriteLine("<------------ Persist Data");
            await DoMyPersistLocalSettings(); 
            await DoMyPersistLocalCache<DataModel>();
            Debug.WriteLine("Persist Data ------------>");

            waitState.Complete();
}

 

Warning: Even on debugging the 5 second time limit is enabled. Don't wait here or step manually through your lines of code.

"Payload file does not exist" compile error

If you write a Windows Metro Style App in Visual Studio 11 Beta and references directly a self written UserControl-DLL you may get the following error:

"Payload file [xyz] does not exist" compile error

 

--> This is a bug.

 

To workaround this, go to the DLL output folder (e.g. bin\Release), create a new folder named like your DLL-Name (e.g. MyUserControlLibrary) and move the XAML files down to this folder.

bin\Release

  MyUserControlLibrary.dll

  MyUserControlLibrary.pri

  \MyUserControlLibrary [folder] <-- create

       UserControl1.xaml <-- move here

       UserControl2.xaml <-- move here

  

Sources:

http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/51111470-8a86-44d4-acb8-e268afa7564e

http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/b20ca4a5-8293-4da7-859e-6759a2a76f9d

String-Resources in WinRT (.RESW)

1) Create a Resource file (Resources.resw) in your project.


2) Add Keys and Values
key1 => Value for Key Nr. 1
key2.Text => Value for Key Nr. 2 and Property Text

 

3) Access the resources 

Use String-Resources from Code

var rl = new ResourceLoader();
var value1 = rl.GetString("key1");
var value2 = rl.GetString("key2/text");

 

Use String-Resources in XAML

<TextBlock x:Uid="key2" Text="Default Text" />

 

4) Support for different languages

Add a Resource-Folder (e.g. "strings")

Add Folders for each language (e.g. "en", "de", "it")

Add a Resources.resw-File into this folders

 

5) Multiple Files

To access strings from the file Errors.resw use this

new ResourceLoader("Errors")

and

<TextBlock x:Uid="/Errors/key2" Text="Default Text" />

 

6) Resources in DLL-Projects

If you want to use a DLL project specific Resources.resw you must specify this

var rl = new ResourceLoader("Dll.Project.Namespace/Resources);

"Dll.Project.Namespace" must be replaced with the real DLL namespace.

 

 

 

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.Commands.Add(cmd1);
   dialog.Commands.Add(cmd2);
   dialog.Commands.Add(cmd3);
   dialog.DefaultCommandIndex = 1;

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