From Yggenyk
Jump to: navigation, search


Show Me The Template is a great tool for looking at default control templates


Visual Studio Designer

Troubleshooting WPF and Silverlight Designer Load Failures


Debugging a Designer Load Failure

To debug a designer load failure

  1. Open a second instance of Visual Studio.
  2. From the Debug menu, choose Attach to Process.
    The Attach To Process dialog box opens.
  3. In the Available Processes section, select the instance of devenv.exe that is loading your XAML and click Attach.
    The Visual Studio debugger attaches to the selected devenv.exe instance.
  4. From the Debug menu, choose Exceptions.
    The Exceptions dialog box opens.
  5. In the Break when exception is list, find the Common Language Runtime Exceptions name, and then check the Thrown check box.
  6. Click OK.
  7. In the first Visual Studio instance that you are debugging, reload the XAML file.
    The second instance of Visual Studio opens and displays the load exception.

Note: You can click Stop Debugging in the second instance of Visual Studio and the first instance keeps running


Standard Date and Time Format Strings

Standard Numeric Format Strings


Label without accelerator

      <ContentPresenter RecognizesAccessKey="False" Content="_123">

Virtualizing an ItemsControl

    <Style x:Key="ItemsControlVirtualisedStyle"
        <Setter Property="VirtualizingStackPanel.IsVirtualizing"
                Value="True" />
        <Setter Property="VirtualizingPanel.IsVirtualizingWhenGrouping"
                Value="True" />
        <Setter Property="VirtualizingPanel.ScrollUnit"
                Value="Pixel" />
        <Setter Property="ScrollViewer.CanContentScroll"
                Value="True" />
        <Setter Property="ScrollViewer.PanningMode"
                Value="VerticalOnly" />
        <Setter Property="ItemsPanel">
                    <VirtualizingStackPanel />
        <Setter Property="Template">
                <ControlTemplate TargetType="ItemsControl">
                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                            Padding="{TemplateBinding Control.Padding}"
                            BorderBrush="{TemplateBinding Border.BorderBrush}"
                            Background="{TemplateBinding Panel.Background}"
                        <ScrollViewer Padding="{TemplateBinding Control.Padding}"
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />

You have to set ScrollViewer.CanContentScroll="True" otherwise you will lose virtualization.

You could set VirtualizingStackPanel.VirtualizationMode="Recycling". This will reduce the numbers of times item containers are created.

Read more on UI virtualization here UI Virtualization | Zag Studio.

Raed more about WPF controls and performance here MSDN - Optimizing Performance: Controls

AffectsMeasure or AffectsArrange