Convert Figma logo to code with AI

ControlzEx logoControlzEx

Shared Controlz for WPF and ... more

1,007
124
1,007
9

Top Related Projects

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.

Google's Material Design in XAML & WPF, for C# & VB.Net.

All the controls missing in WPF. Over 1 million downloads.

2,598

Modern UI for WPF

Dragable and tearable tab control for WPF

WPF Ribbon control like in Office

Quick Overview

ControlzEx is a set of shared controls and helper classes for WPF (Windows Presentation Foundation) applications. It provides enhanced versions of standard WPF controls and additional utilities to simplify common tasks in WPF development. ControlzEx is designed to be easily integrated into existing projects and offers improved functionality and customization options.

Pros

  • Enhances standard WPF controls with additional features and improved behavior
  • Provides helper classes and utilities for common WPF development tasks
  • Easily integrable into existing WPF projects
  • Actively maintained and regularly updated

Cons

  • Limited to WPF applications, not applicable for other UI frameworks
  • May introduce additional dependencies to your project
  • Learning curve for developers unfamiliar with the library's specific implementations
  • Some controls may have different behavior compared to standard WPF controls, requiring adaptation

Code Examples

  1. Using the WindowChrome for custom window styling:
<Window x:Class="MyApp.MainWindow"
        xmlns:controlzex="urn:controlzex">
    <controlzex:WindowChrome.WindowChrome>
        <controlzex:WindowChrome 
            GlassFrameThickness="1" 
            CornerRadius="0" 
            CaptionHeight="30"/>
    </controlzex:WindowChrome.WindowChrome>
    <!-- Window content -->
</Window>
  1. Implementing a PopupEx for improved popup behavior:
<controlzex:PopupEx IsOpen="{Binding IsPopupOpen}" 
                    StaysOpen="False" 
                    AllowTopMost="True">
    <Border Background="White" BorderBrush="Gray" BorderThickness="1">
        <TextBlock Text="This is a PopupEx" Padding="10"/>
    </Border>
</controlzex:PopupEx>
  1. Using the KeyboardNavigationEx attached property:
<StackPanel controlzex:KeyboardNavigationEx.DirectionalNavigation="Cycle">
    <TextBox Text="Field 1"/>
    <TextBox Text="Field 2"/>
    <TextBox Text="Field 3"/>
</StackPanel>

Getting Started

  1. Install the ControlzEx NuGet package in your WPF project:

    Install-Package ControlzEx
    
  2. Add the ControlzEx namespace to your XAML:

    xmlns:controlzex="urn:controlzex"
    
  3. Start using ControlzEx controls and utilities in your WPF application:

    <controlzex:BadgedEx Badge="42">
        <Button Content="Notifications"/>
    </controlzex:BadgedEx>
    

Competitor Comparisons

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.

Pros of MahApps.Metro

  • Comprehensive UI toolkit with a wide range of controls and styles
  • Active community and regular updates
  • Extensive documentation and examples

Cons of MahApps.Metro

  • Larger footprint and potential performance impact
  • Steeper learning curve due to its extensive feature set
  • May require more setup and configuration

Code Comparison

ControlzEx:

public class KeyboardNavigationEx
{
    public static readonly DependencyProperty TabOnceActiveElementProperty = ...
    public static void SetTabOnceActiveElement(UIElement element, UIElement value) => ...
    public static UIElement GetTabOnceActiveElement(UIElement element) => ...
}

MahApps.Metro:

public class MetroWindow : Window
{
    public static readonly DependencyProperty ShowTitleBarProperty = ...
    public bool ShowTitleBar
    {
        get => (bool)GetValue(ShowTitleBarProperty);
        set => SetValue(ShowTitleBarProperty, value);
    }
}

ControlzEx focuses on enhancing existing WPF controls with additional functionality, while MahApps.Metro provides a complete UI toolkit with custom controls and styles. ControlzEx is more lightweight and easier to integrate into existing projects, whereas MahApps.Metro offers a more comprehensive solution for creating modern UI applications but may require more resources and setup time.

Google's Material Design in XAML & WPF, for C# & VB.Net.

Pros of MaterialDesignInXamlToolkit

  • Provides a comprehensive set of Material Design-inspired controls and styles for WPF applications
  • Offers a rich set of themes and color schemes, allowing for easy customization
  • Includes a large community and extensive documentation

Cons of MaterialDesignInXamlToolkit

  • Larger footprint and potentially higher resource usage due to its extensive feature set
  • May require more setup and configuration compared to ControlzEx's simpler approach
  • Steeper learning curve for developers new to Material Design concepts

Code Comparison

MaterialDesignInXamlToolkit:

<materialDesign:Card Padding="32" Margin="16">
    <TextBlock Style="{DynamicResource MaterialDesignHeadline6TextBlock}">
        Hello World
    </TextBlock>
</materialDesign:Card>

ControlzEx:

<controls:MetroWindow x:Class="MainWindow"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls">
    <TextBlock>Hello World</TextBlock>
</controls:MetroWindow>

MaterialDesignInXamlToolkit focuses on providing Material Design components, while ControlzEx offers more general-purpose controls and window management features. The choice between the two depends on the specific needs of your project and the desired visual style.

All the controls missing in WPF. Over 1 million downloads.

Pros of wpftoolkit

  • Extensive collection of WPF controls and components
  • Regular updates and active community support
  • Comprehensive documentation and examples

Cons of wpftoolkit

  • Larger footprint and potential performance impact
  • Some features require a commercial license
  • Steeper learning curve due to the wide range of components

Code Comparison

ControlzEx:

public class WindowChrome : FrameworkElement
{
    public static readonly DependencyProperty CaptionHeightProperty =
        DependencyProperty.Register(nameof(CaptionHeight), typeof(double), typeof(WindowChrome), new PropertyMetadata(0d));
}

wpftoolkit:

public class PropertyGrid : Control
{
    public static readonly DependencyProperty SelectedObjectProperty =
        DependencyProperty.Register("SelectedObject", typeof(object), typeof(PropertyGrid),
            new PropertyMetadata(null, OnSelectedObjectChanged));
}

Both libraries provide custom WPF controls, but ControlzEx focuses on enhancing existing Windows functionality, while wpftoolkit offers a broader range of UI components. ControlzEx is more lightweight and specialized, making it suitable for projects requiring specific window chrome customizations. wpftoolkit, on the other hand, provides a comprehensive set of controls but may introduce more complexity and potential licensing considerations for commercial projects.

2,598

Modern UI for WPF

Pros of MUI

  • More comprehensive UI toolkit with a wider range of controls and components
  • Better documentation and examples for developers
  • Active community and regular updates

Cons of MUI

  • Larger footprint and potentially higher resource usage
  • Steeper learning curve due to more complex architecture
  • May introduce unnecessary dependencies for simpler projects

Code Comparison

MUI:

<mui:ModernWindow x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mui="http://firstfloorsoftware.com/ModernUI"
    Title="MainWindow" Height="350" Width="525">
</mui:ModernWindow>

ControlzEx:

<controlzex:WindowChrome.WindowChrome>
    <controlzex:WindowChrome 
        GlassFrameThickness="1" 
        CornerRadius="0" 
        CaptionHeight="30"/>
</controlzex:WindowChrome.WindowChrome>

MUI provides a more complete window solution with built-in modern UI elements, while ControlzEx focuses on enhancing existing WPF controls with additional functionality. MUI's approach may be more suitable for larger applications seeking a cohesive modern look, whereas ControlzEx offers more flexibility for customizing individual controls within an existing application structure.

Dragable and tearable tab control for WPF

Pros of Dragablz

  • Specialized in creating draggable and dockable tab controls
  • Offers advanced tab layout capabilities, including tab tearing and merging
  • Provides a more visually appealing and modern UI out of the box

Cons of Dragablz

  • More focused on tab controls, less versatile for general WPF development
  • May have a steeper learning curve due to its specialized features
  • Less actively maintained compared to ControlzEx

Code Comparison

Dragablz:

<dragablz:TabablzControl>
    <dragablz:TabablzControl.InterTabController>
        <dragablz:InterTabController />
    </dragablz:TabablzControl.InterTabController>
    <TabItem Header="Tab 1">Content 1</TabItem>
    <TabItem Header="Tab 2">Content 2</TabItem>
</dragablz:TabablzControl>

ControlzEx:

<controls:MetroWindow x:Class="MainWindow"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls">
    <Grid>
        <!-- Your content here -->
    </Grid>
</controls:MetroWindow>

The code snippets demonstrate the primary focus of each library: Dragablz on tab controls and ControlzEx on general WPF controls and window management.

WPF Ribbon control like in Office

Pros of Fluent.Ribbon

  • Provides a complete Ribbon control implementation for WPF applications
  • Offers a wide range of built-in Ribbon elements and controls
  • Supports Office-like UI styling out of the box

Cons of Fluent.Ribbon

  • More complex and heavyweight compared to ControlzEx
  • May have a steeper learning curve for developers new to Ribbon interfaces
  • Less flexible for custom control implementations

Code Comparison

Fluent.Ribbon:

<Fluent:Ribbon>
    <Fluent:RibbonTabItem Header="Home">
        <Fluent:RibbonGroupBox Header="Group">
            <Fluent:Button Header="Button" />
        </Fluent:RibbonGroupBox>
    </Fluent:RibbonTabItem>
</Fluent:Ribbon>

ControlzEx:

<Controls:MetroWindow>
    <Controls:WindowCommands>
        <Button Content="Settings" />
    </Controls:WindowCommands>
</Controls:MetroWindow>

ControlzEx focuses on providing enhanced base controls and window management, while Fluent.Ribbon specializes in implementing the Ribbon interface. ControlzEx is more lightweight and flexible, suitable for various UI designs. Fluent.Ribbon is ideal for applications requiring a full Ribbon UI, but may be overkill for simpler interfaces.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README



ControlzEx

Shared Controlz for WPF

Supporting .NET Framework (4.6.2 and greater) and .NET (6 and greater)

ControlzEx

Build status Release Downloads Issues Nuget License

Twitter Jan Twitter Bastian Twitter James

Let's get started

  • A history of changes is maintained in the Changelog.
  • The roadmap is done by milestones.
  • Releases and Release Notes
  • Development requirements
    • .NET SDK 8.0.401 or later
    • An IDE that supports the required .NET SDK (for example Rider 2024.1, Visual Studio 2022 (17.10) or later)

TextBoxInputMaskBehavior

The TextBoxInputMaskBehavior can be used to show a mask inside a TextBox.

Note: It's only a mask and does not validate your text.

<TextBlock Grid.Row="0"
           Grid.Column="0"
           Margin="4"
           Text="Datetime" />
<TextBox Grid.Row="0"
         Grid.Column="1"
         Margin="4">
    <behaviors:Interaction.Behaviors>
        <controlzEx:TextBoxInputMaskBehavior InputMask="00/00/0000" />
    </behaviors:Interaction.Behaviors>
</TextBox>

<TextBlock Grid.Row="1"
           Grid.Column="0"
           Margin="4"
           Text="Phone Number" />
<TextBox Grid.Row="1"
         Grid.Column="1"
         Margin="4">
    <behaviors:Interaction.Behaviors>
        <controlzEx:TextBoxInputMaskBehavior InputMask="( 999 ) 000 000 - 00"
                                             PromptChar="_" />
    </behaviors:Interaction.Behaviors>
</TextBox>

The original TextBoxInputMaskBehavior was taken from from Blindmeis's Blog.

InputMaskScreenshot

KeyboardNavigationEx

The KeyboardNavigationEx is a helper class for a common focusing problem. The focus of an UI element itself isn't the problem. But if we use the common focusing methods, the control gets the focus, but it doesn't get the focus visual style.

The original KeyboardNavigation class handles the visual style only if the control gets the focus from a keyboard device or if the SystemParameters.KeyboardCues is true.

With KeyboardNavigationEx you can fix this in two simple ways.

In code behind:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += (s, e) => { KeyboardNavigationEx.Focus(this.TheElementWhichShouldGetTheFocus); };
    }
}

or in XAML:

<Button controlzex:KeyboardNavigationEx.AlwaysShowFocusVisual="True">Hey, I get the focus visual style on mouse click!</Button>

keyboardfocusex

AutoMove ToolTip

An auto moving ToolTip. More Info.

<Button Margin="5"
        Padding="5"
        Content="Test Button 2"
        ToolTipService.ShowDuration="20000">
    <Button.ToolTip>
        <ToolTip local:ToolTipAssist.AutoMove="True">
            <ToolTip.Template>
                <ControlTemplate>
                    <Grid>
                        <Border Background="Gray"
                                BorderBrush="Black"
                                BorderThickness="1"
                                Opacity="0.9"
                                SnapsToDevicePixels="True" />
                        <TextBlock Margin="5"
                                    Foreground="WhiteSmoke"
                                    FontSize="22"
                                    Text="ToolTipHelper AutoMove sample"
                                    TextOptions.TextFormattingMode="Display"
                                    TextOptions.TextRenderingMode="ClearType" />
                    </Grid>
                </ControlTemplate>
            </ToolTip.Template>
        </ToolTip>
    </Button.ToolTip>
</Button>

automove_tooltip2

automove_tooltip

GlowWindowBehavior

The GlowWindowBehavior adds a Glow around your window.
Starting with Windows 11 the behavior can be used to control the color of the native window border and automatically does so, when Windows 11 is detected.
This can be turned off by setting PreferDWMBorder to false.

WindowChromeBehavior

ControlzEx provides a custom chrome for WPF windows and some other deeper fixes for it.

What it does provide:

  • Draw anywhere inside the window (including the titlebar)
  • Supports every WindowStyle (None, SingleBorderWindow, ThreeDBorderWindow and ToolWindow)
  • Supports jitter free window resizes
  • Allows you to ignore the taskbar when the window is maximized
  • Provides an IsNCActive property
  • Mitigates a bug in Windows that causes newly shown windows to briefly be shown with a pure white background
  • Starting with Windows 11:
    • Allows you to control rounded corners (through CornerPreference)
    • Supports snap menu on window buttons (through attached properties like NonClientControlProperties.HitTestResult and NonClientControlProperties.ClickStrategy)

Most of the fixes and improvements are from MahApps.Metro and Fluent.Ribbon.

Concrete implementation of techniques described here:

Blog entry from Microsoft on custom Window chrome

It's a fork of the original Microsoft WPF Shell Integration Library. Current Microsoft's implementation can be found:

PopupEx

Custom Popup that can be used in validation error templates or something else like in MaterialDesignInXamlToolkit or MahApps.Metro.

PopupEx provides some additional nice features:

  • repositioning if host-window size or location changed
  • repositioning if host-window gets maximized and vice versa
  • it's only topmost if the host-window is activated

2015-10-11_01h03_05

TabControlEx

Custom TabControl that keeps the TabItem content in the VisualTree while unselecting them, so no re-create nightmare is done, after selecting the TabItem again. The visibility behavior can be set by ChildContentVisibility dependency property.

Usage:

<controlz:TabControlEx>
    <TabItem Header="Lorem">
        <TextBlock Text="Lorem ipsum dolor sit amet, consetetur sadipscing"
                   HorizontalAlignment="Center"
                   FontSize="30" />
    </TabItem>
    <TabItem Header="ipsum">
        <TextBox Text="Lorem ipsum dolor sit amet, consetetur sadipscing"
                 HorizontalAlignment="Center"
                 Margin="5" />
    </TabItem>
</controlz:TabControlEx>

PackIconBase

A base class to help drive a common method for creating icon packs in WPF.

To create a new icon pack follow these steps:

Define a key (typically an enum):

public enum PackIconKind
{
    Happy,
    Sad
}

Subclass PackIconBase, adding

  • Default style key
  • A factory providing Path data for each key
public class PackIcon : PackIconBase<PackIconKind>
{
    static PackIcon()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIcon), new FrameworkPropertyMetadata(typeof(PackIcon)));
    }

    public PackIcon() : base(CreateIconData)
    { }

    private static IDictionary<PackIconKind, string> CreateIconData()
    {
        return new Dictionary<PackIconKind, string>
        {
            {PackIconKind.Happy, "M20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M10,9.5C10,10.3 9.3,11 8.5,11C7.7,11 7,10.3 7,9.5C7,8.7 7.7,8 8.5,8C9.3,8 10,8.7 10,9.5M17,9.5C17,10.3 16.3,11 15.5,11C14.7,11 14,10.3 14,9.5C14,8.7 14.7,8 15.5,8C16.3,8 17,8.7 17,9.5M12,17.23C10.25,17.23 8.71,16.5 7.81,15.42L9.23,14C9.68,14.72 10.75,15.23 12,15.23C13.25,15.23 14.32,14.72 14.77,14L16.19,15.42C15.29,16.5 13.75,17.23 12,17.23Z"},
            {PackIconKind.Sad, "M20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M15.5,8C16.3,8 17,8.7 17,9.5C17,10.3 16.3,11 15.5,11C14.7,11 14,10.3 14,9.5C14,8.7 14.7,8 15.5,8M10,9.5C10,10.3 9.3,11 8.5,11C7.7,11 7,10.3 7,9.5C7,8.7 7.7,8 8.5,8C9.3,8 10,8.7 10,9.5M12,14C13.75,14 15.29,14.72 16.19,15.81L14.77,17.23C14.32,16.5 13.25,16 12,16C10.75,16 9.68,16.5 9.23,17.23L7.81,15.81C8.71,14.72 10.25,14 12,14Z"}
        };
    }
}

Provide a default style (typically in your Generic.xaml, e.g:

<Style TargetType="{x:Type local:PackIcon}">
    <Setter Property="Height" Value="16" />
    <Setter Property="Width" Value="16" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalAlignment" Value="Top" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:PackIcon}">
                <Viewbox>
                    <Canvas Width="24" Height="24">
                        <Path Data="{Binding Data, RelativeSource={RelativeSource TemplatedParent}}"
                              Fill="{TemplateBinding Foreground}" />
                    </Canvas>
                </Viewbox>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Your users should now have a simple way to use your icon pack in their applications:

<ns:PackIcon Kind="HappyIcon" />

Theming

ControlzEx provides a ThemeManager which helps you to provide Theming to your App.
For more information see this section.

Licence

The MIT License (MIT)

Copyright (c) since 2015 Jan Karger, Bastian Schmidt, James Willock

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.