ViewHandler 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package ViewHandler --version 1.0.4                
NuGet\Install-Package ViewHandler -Version 1.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ViewHandler" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ViewHandler --version 1.0.4                
#r "nuget: ViewHandler, 1.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ViewHandler as a Cake Addin
#addin nuget:?package=ViewHandler&version=1.0.4

// Install ViewHandler as a Cake Tool
#tool nuget:?package=ViewHandler&version=1.0.4                

ViewHandler

ViewHandler is a .NET class library that provides a range of utility methods for working with user interface elements in desktop applications.


Documentation of Methods


ChangeElementForeground

ChangeElementForeground<T>(T element, Color color):

Changes the foreground color of a single FrameworkElement object element to the specified color parameter, which is of type Color. If the element is of type Control, its Foreground property will be set to a new SolidColorBrush object with the specified color. This method has a generic type parameter T, which must be a subclass of FrameworkElement.

To call this method, use the following syntax : ViewHandler.ChangeElementForeground<FrameworkElement>(colorObject, elementObject);


ChangeElementsForeground

ChangeElementsForeground<T>(Color color, params T[] elements):

Changes the foreground color of multiple FrameworkElement objects passed as parameters, using a params array of type T[]. For each element in the array, the method checks if it is of type Control, and if so, sets its Foreground property to a new SolidColorBrush with the specified color. This method has a generic type parameter T, which must be a subclass of FrameworkElement.

To call this method, use the following syntax : ViewHandler.ChangeElementsForeground<FrameworkElement>(colorObject, elementObject1, elementObject2, elementObject3);


ChangeElementBackground

ChangeElementBackground<T>(T element, Color color):

Changes the background color of a single FrameworkElement object element to the specified color parameter, which is of type Color. If the element is of type Control, its Background property will be set to a new SolidColorBrush object with the specified color. This method has a generic type parameter T, which must be a subclass of FrameworkElement.

To call this method, use the following syntax : ViewHandler.ChangeElementBackground<FrameworkElement>(colorObject, elementObject);


ChangeElementsBackground

ChangeElementsBackground<T>(Color color, params T[] elements):

Changes the background color of multiple FrameworkElement objects passed as parameters, using a params array of type T[]. For each element in the array, the method checks if it is of type Control, and if so, sets its Background property to a new SolidColorBrush with the specified color. This method has a generic type parameter T, which must be a subclass of FrameworkElement.

To call this method, use the following syntax : ViewHandler.ChangeElementsBackground<FrameworkElement>(colorObject, elementObject1, elementObject2, elementObject3);


OpenNewWindow

OpenNewWindow(Type window):

Creates and shows a new Window object of the specified Type parameter, which must be a subclass of the Window class. The method checks if the Type parameter is a subclass of Window using the IsSubclassOf method. If not, an ArgumentException is thrown. The method uses reflection to create an instance of the specified Type parameter at runtime, and then shows the new window using its Show method.

To call this method, use the following syntax : ViewHandler.OpenNewWindow(typeof(WindowClass));


CloseWindow

CloseWindow(Window window):

Closes the specified Window object by calling its Close method.

To call this method, use the following syntax : ViewHandler.CloseWindow(windowObject);

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 262 2/19/2023
1.0.4 238 2/18/2023

Fixed an error with the ChangeElementBackground that caused the method to change the foreground instead.