How to disable hardware rendering for a WPF process

Apparently, my customers do not have the WPF black screen bug (Video Rendering Issues for WPF Windows – Rick Strahl’s Web Log) but the solution is elegant enough to be noted.

With some video card/drivers, WPF’s main window (and more particularilly MahApps main window) can be completly black. This seems to be an hardware rendering problem. Good news, a per processs solution exist:

System.Windows.InteropRenderOptions.ProcessRenderMode

that can be set at startup to SoftwareOnly. Good to know!

Ammy, a better syntax than XAML with more (and a big drawback)

In a first approach, Ammy could be just a better json based syntax for xaml. And there is more:

  • global and local variables
$fontColor = "#363636"

 can be reused:

TextBlock {
  Foreground: $fontColor
}
  • Aliases can be seen as a function returning a node:
alias Header(text) {
  TextBlock {
    FontSize: 18
    Text: $text
  }
}

can be easily used :

StackPanel {
  @Header("First chapter") {
  }
}
  • and mixins can be seen as function providing a set of properties:
mixin SeeThrough(opacity=0.5) for UIElement {
  Opacity: $opacity
}
Button {
  #SeeThrough()
}

or sub node(s):

mixin DefaultItem() for ComboBox {
  ComboBoxItem {
    "Select quantity"
  }
}
ComboBox {
    #DefaultItem()
}

or

mixin TwoRows(height1, height2) for Grid {
  RowDefinitions: [
    RowDefinition { Height: $height1 }
    RowDefinition { Height: $height2 }
  ]
}
Grid {
  #TwoRows(25, "*")
}

and are composable.

UWP is said to be coming soon but what about Xamarin forms?

This is all well and good except a big drawback: it’s not free, should be paid monthly and is extremely expensive ($299 per month for commercial project made by more than a single developer). So it’s unusable. I’m not going to invest my time to learn a new graphical language if I’m sure to be able to use it anywhere! What a pity!

Even without a VS designer, such a refresh could be extremely useful but this should be a community effort and not a commercial one to be successful.

 

NHotkey

A library providing an elegant extension to WPF key binding:

<Window.InputBindings>
        <KeyBinding Gesture="Ctrl+Alt+Add" Command="{Binding IncrementCommand}"
                    HotkeyManager.RegisterGlobalHotkey="True" />
        <KeyBinding Gesture="Ctrl+Alt+Subtract" Command="{Binding DecrementCommand}"
                    HotkeyManager.RegisterGlobalHotkey="True" />
    </Window.InputBindings>

to register global hotkeys.

thomaslevesque/NHotkey · GitHub.