This is a base libraries for building WPF application with the MVVM design pattern.
- ATC.Net WPF
- Table of contents
Nuget package | Description | Dependencies |
---|---|---|
Atc.Wpf | Base Controls, ValueConverters, Extensions etc. | Atc & Atc.Wpf.SourceGenerators |
Atc.Wpf.Controls | Miscellaneous UI Controls | Atc.Wpf & Atc.Wpf.Theming |
Atc.Wpf.Controls.Sample | Controls for creating WPF sample apps | Atc.Wpf & Atc.Wpf.Theming |
Atc.Wpf.FontIcons | Render Svg and Img resources based on fonts | Atc.Wpf |
Atc.Wpf.Theming | Theming for Light & Dark mode for WPF base controls | Atc.Wpf |
The demonstration application, Atc.Wpf.Sample
, functions as a control explorer.
It provides quick visualization of a given control, along with options for
copying and pasting the XAML markup and/or the C# code for how to use it.
The following example is taken from the ReplayCommandAsync which illustrates its usage:
- The
Sample
tab shows how to use the control or feature. - The
XAML
tab displays the corresponding XAML markup. - The
CodeBehind
tab reveals the underlying code-behind. - The
ViewModel
tab displays the associated ViewModel, if used. - The
Readme
tab displays the associated [control]_Readme.md, if exist.
Sample ![]() |
XAML ![]() |
CodeBehind ![]() |
ViewModel ![]() |
Light-Mode | Dark-Mode |
---|---|
Wpf - AutoGrid ![]() |
Wpf - AutoGrid ![]() |
Wpf.Controls - Label MIX ![]() |
Wpf.Controls - Label MIX ![]() |
Wpf.Theming - ImageButton ![]() |
Wpf.Theming - ImageButton ![]() |
Wpf.FontIcons - Viewer ![]() |
Wpf.FontIcons - Viewer ![]() |
First of all, include Nuget packages in the .csproj
file like this:
<ItemGroup>
<PackageReference Include="Atc.Wpf" Version="2.0.178" />
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.178" />
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.178" />
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.178" />
</ItemGroup>
Then update App.xaml
like this:
<Application
x:Class="Atc.Wpf.Sample.App"
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
[other namespaces]>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Atc.Wpf.Theming;component/Styles/Default.xaml" />
<ResourceDictionary Source="pack://application:,,,/Atc.Wpf.Controls;component/Styles/Controls.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Now it is possible to use controls with theming and default WPF controls like TextBox, Button etc. with theme style.
Note: Right now, it is a limit amount of controls and components there is documented with a Readme.md
file.
Therefore run the Atc.Wpf.Sample
application to explore all the controls and components. :-)
- GridEx
- StaggeredPanel
- UniformSpacingPanel
- SvgImage
- Control Helpers
In MVVM, certain attributes help automate boilerplate code using source generators.
Example for ViewModel classes
For more details, see the MVVM section.
[DependencyProperty<bool>("IsRunning")]
public partial class MyControl : UserControl
{
}
[DependencyProperty<bool>("IsRunning"]
public partial class MyControl : UserControl
{
}
public partial class MyControl
{
public static readonly DependencyProperty IsRunningProperty = DependencyProperty.Register(
nameof(IsRunning),
typeof(bool),
typeof(MyControl),
new FrameworkPropertyMetadata(defaultValue: BooleanBoxes.TrueBox);
public bool IsRunning
{
get => (bool)GetValue(IsRunningProperty);
set => SetValue(IsRunningProperty, value);
}
}
public partial class MyControl
{
public static readonly DependencyProperty IsRunningProperty = DependencyProperty.Register(
nameof(IsRunning),
typeof(bool),
typeof(MyControl),
new FrameworkPropertyMetadata(
defaultValue: BooleanBoxes.TrueBox,
propertyChangedCallback: PropertyChangedCallback,
coerceValueCallback: CoerceValueCallback,
flags: FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender,
defaultUpdateSourceTrigger: UpdateSourceTrigger.Default,
isAnimationProhibited: true));
public bool IsRunning
{
get => (bool)GetValue(IsRunningProperty);
set => SetValue(IsRunningProperty, value);
}
}