Enum filter controls

For having a CheckBox selection for enum type like this

and make easy filter on collection

you can use this two components

  • EnumFilterControl
  • EnumFilterComboControl

EnumFilterControl

Is base control for showing enum in grid

EnumFilterComboControl

Is the same control but using ComboBox

Extra code

Styles

Common properties

Properties Descriptions Default
Title Title for control (show at left) Filter
ShowHiddenEnum Define if you must show item of enum with ExcludeFilterAttribute false

if you have an enum with (usage of attribues)

in this case when ShowHiddenEnum=true, you can show None and All

And if you use HideFilterColorAttribute on enum like this

Force to hide color even ShowColor=true

Properties Descriptions Default
ItemConverter For specify class can convert Items (IValueConverter) for color indicator and text translation or try to use TypeConverter null

TypeConverter if define, like this

usage like this

or use a TypeConverter like this

for TypeConverter the converting is automatic

Properties Descriptions Default
ShowColor define if rectangle color is visible and ItemsConverter is define for color (not return null) or TypeConverter exist and can convert to Brush true
ShowAll Show All CheckBox true
ShowNone Show None CheckBox true
AllText Text for All CheckBox true
NoneText Text for None CheckBox true
Selector Is the selectedItems for this component with

  • null if all selected
  • object[] empty if none selected
  • object[] contains enum element checked
null
AllowAll do not use, is used for disable all checkbox
AllowNone do not use, is used for disable none checkbox
All do not use, is used for check all checkbox
None do not use, is used for checknone checkbox
CheckWith for specify size of CheckBox if you want 80D
Type Is the type of enum you want to show null

Usage

in xaml

for filtering

Categories: Non classé Tags:

SelectedItems for ListView

SelectedItems not exist for LisView you can use this code for adding this property and using binding

and usage like this

 

Categories: Non classé Tags:

ValidationRules with binding

It’s not possible to have a binding in ValidationRule because this validation rule class is not in visual hierachical tree, and sometime is necessary to chech for example is the text is not in list of the DataContext or or two DateTime, start and end are consistent together.

See my sample for Text and List in DataContext

Window for test

and xaml

and two class for using

DataContextObject for storing DataContext of TextBox

and ValitationRule

see more sample in

https://stackoverflow.com/questions/3862385/wpf-validationrule-with-dependency-property

https://docs.microsoft.com/fr-fr/dotnet/desktop/wpf/data/how-to-implement-binding-validation?view=netframeworkdesktop-4.8

and if you want to have best design of error for ValidationRule

here somes template for validation error

and for factorize for all textbox

 

Categories: Non classé Tags:

Palette control

PaletteControl is control to show Numeric, Letter, Word(s), Image, Time, stringg and array of string like train panel indicators in station


it’s a package contains many control for show this and it s full customizable

you can find

Control Descriptions Animated
BasePaleteControl Base control (has no animation) No
PaletteContentControl Control for show somes content, and run animation when it change Yes
PaletteTextControl for animating text Yes
PaletteCharControl for animating char using allowedChar string Yes
PaletteNumericControl for animation char number Yes
PaletteTimeControl for showing current time Yes
PaletteStringControl for animating one string to other one string Yes
PaletteArrayControl for animation array of string Yes

 

Properties for all

Property Descriptions
AdjustTop allow to move content top
CornerRadius corner radius for control
LineColor define line color at the vertical center of control
ShowLine set if line is visible
ContentLine to replace to common line by control you want (when you use ShowLine = false)

otherwize you can set properties background, forground, borderbrush, bordertickness to set your content

Properties for animated control

Property Descriptions
AnimationTime Define time for release palette animation

Specific properties

 

BasePaletteControl & PaletteContentControl

Property Descriptions
Content content of control

 

PaletteTextControl

Property Descriptions
Text
Text for control (multi char) animation start when text change

 

PaletteCharControl

this control animate char from previous char (current) to new setted char with AllowedChar string

For sample : if you have « abcdef » in AllowedChar, this current char is a, and set d, you have an animation a->b, b->c, c->d

Property Descriptions
char
Char to set
AllowedChar
string for define allowed char, animation use it
CaseSensitive
if case sensitive if used to find char in AllowedChar
Text
Do not use

 

PaletteNumericControl

is the same work as PaletteCharControl but AllowedChar is not available and set directly a « 0123456789 »

Property Descriptions
Value int value to set
Text
Do not use

 

PaletteTimeControl

is a control to show current time, you can pause it on using IsPaused (not browsable) dependency property

 

Property Descriptions
MarginNumber
margin between two number in pixel
NumberMode
mode for show part of time, one char for each number or two number
NumericBackground
background for numeric palette
NumericBorderBrush
border brush for numeric palette
NumericBorderThickness
border thickness for numeric palette
NumericCornerRadius
corner radius for numeric palette
NumericHeight
height for numeric palette
NumericWidth
width for numeric palette
ShowSecond if you want to show second number
Separator Content for separator for hour-minute and minute-second (can’t use binding for separator because the Separator ar dupplicated)
SeparatorHour Content for separator for hour-minute
SeparatorSecond Content for separator for minute-second
IsPaused define if time running

and event SecondTick raised for each second

the common properties background, forground, borderbrush, bordertickness to set all content of this control

 

PaletteStringControl

is a control to show string, after define number of char define.

Property Descriptions
AllowedChar
same as PaletteTextControl
Casesensitive
same as PaletteTextControl
CharBackground
background for each char palette
CharBorderBrush
border brush for each char palette
CharBorderThickness
border thickness for each char palette
CharCornerRadius
corner radius for each char palette
CharCount
number of char allowed (define number of palette showed)
CharHeight
height for each char palette
CharWidth
width for each char palette
CharMargin
margin between two char

and event CompletAnim raised when animation is done

the common properties background, forground, borderbrush, bordertickness to set all content of this control

you can change color for each text palette for setting ArrayBrush (dependency property) like this

by default color is white

 

PaletteArrayControl

is ths same control as string but using an array of string to set animation to all string in array with pause between two string.

properties are same as PaletteString Control with Pause (dependency property) for setting pause between to string

the common properties background, forground, borderbrush, bordertickness to set all content of this control

you can change color for each text palette for setting ArrayBrush (dependency property) like this

by default color is white

and you can set or clear Array

Source code

All this controls are contained in UltimateCorp.Palette.dll and set in xmlns= »http://schemas.microsoft.com/winfx/2006/xaml/presentation »
also you can used directly without specify other namespace

this control are made in .net 6 made with visual studio 2022

you can find test executable PaletteExecutable

and complete project Test Palette v2

Categories: Non classé Tags:

Acces to property hidden field

If yyou want to acces easily you can show this post

https://gunnarpeipman.com/csharp-automatic-properties/#:~:text=Automatic%20property%20in%20C%23%20is,field%20or%20assign%20to%20it.&text=We%20can%20use%20attributes%20in,properties%20because%20features%20in%20different%20.

use Mono.Reflection as nuget https://github.com/jbevain/mono.reflection/

and use with

behind

see extension for sample

 

Categories: Non classé Tags:

ToolBoxIcon for wpf Control

Categories: Non classé Tags:

Popup helper for close it on click

If you want to close a Popup automatically when click on it or children, use this helper

and

see  http://ultimatespy.sytes.net/wpf/index.php/2022/03/30/togglebutton-to-control-popup/  for ToggleButtonHelper

Categories: Non classé Tags:

ToggleButton to control Popup

When you must control a Popup with ToggleButton you can bind IsOpen of Popup to IsChecked of ToggleButton and set StaysOpen of Popup to false

but in this cas when the Popup is open and you click another time on ToggleButton, the Popup close and reopen immediatly

for having a better result on click on ToggleButton when Popup is open you can use this Helper

and use like this

 

Categories: Non classé Tags:

ListView Columns Arrange, Sort, Filter, Save with no code behind

Warning

Filter sort are not tested with set of big data

For using this, load and see project below (visual studio 2022/ .net 6.0)

Components

For using then you can add to yours <GridView> the two controls

  • local:GridViewColumnEx overrided from GridViewColumn
  • local:GridViewColumnHeaderEx overrided from GridViewColumnHeader

properties for both

Properties Descriptions
CanFilter define column has filter [default = false]
if set to true, filter icon is visible when FilterEditor is correct for datatype
CanSort define column can sorted [default =false]
CanResize define column can resized [default = true]
if set to false, the separator of column is black
CanHide define column can hided [default = false]
if set to true, hide iconis visible
CanMove define column can moved [default = true]
if set to false, DisableMoveColor is applyed
Profil define profil for column (see profils) [default = empty]
FilterEditor Define editor used for filtering (see Editor)
ColumnBindingName Define name of binding of trade object (no necessary to use DisplayMemberBinding)
HorizontalContentAlignment Define position of header in column header (right, center, left) [default = left]
right
center
Left
HideToolTip ToolTip text for hide icon [default = « Hide column »]
FilterToolTip ToolTip text for filter icon [default = « Filter column »]
DisableMoveColor Disable move color for header when CanMove = false [default = #10000000]
FilterIndicatorColor Color of filter icon when filter exists [default = Green]
MinColumnWidth Minimum size for header [default = 50d]

properties for local:GridViewColumnEx

Properties Descriptions
Header from GridViewColumn with same usage

propertie for local:GridViewColumnHeaderEx

Properties Descriptions
Content from GridViewColumnHeader with same usage

Structure

You can use

  • only GridViewColumnEx
  • GridViewColumnEx with CellTemplate
  • GridViewColumn with GridViewColumnHeaderEx inside
  • GridViewColumn with CellTemplate and GridViewColumnHeaderEx inside

see MainWindowStructure.xaml for sample

Editors

the editors are those which make it possible to filter the elements in columns. You can choose for a data type in the column the type of editor you want to have (and behavior)
it set in EditorFilter property (with flag enum) set with ‘,’

Data type Description
Integer See MainWindowInteger.xaml for sample
String See MainWindowString.xaml for sample
Boolean See MainWindowBool.xaml for sample
DateTime See MainWindowDate.xaml for sample
Enum See MainWindowEnum for sample
for enum you can use a TypeConverter for showing value as you want
see in trade.cs enum EStatus and TypeConverter EStatusConverter

You can see sample in MainWindowEditor.xaml for mixing data and editor

You can also define your own editor by redefining the data model for the editor based on Datatype you can find a the end of generic.xaml.
Classes of editor override from BaseFilter (see in FilterClasses.cs)
For sample you can see MainWindowDesign.xaml (in windows resources for redefine)

Profils

the profiles are made to quickly define a presentation by hiding the columns which have at least one profil and whose profile is or is not in the selected one.

for sample if you have columns A, B, C, D (profils are set by string separate by ‘,‘)

Column Profil
A (empty or not define)
B alpha,beta
C beta,gamma
D alpha,gamma

If you set profil to

Profil Columns showed
alpha
  • A (no profile define)
  • B
  • D
beta
  • A (no profile define)
  • B
  • C
gamma
  • A (no profile define)
  • C
  • D

To have a better presentation of the profiles you can add a converter to have personalized viewed texts
for sample i transmform in a converter a,b,c profils text to alpha, beta, gamma texts
with attached property local:ProfilHelper.Converter set in ListView
see ProfilTextConverter.cs 

Like local:ProfilHelper.Converter= »{local:ProfilTextConverter} » see in MainWindowProfil.xaml

Other

ContextMenus

You can have 3 context menu on columns by clicking right on GridViewColumnsHeader

  • Normal context menu (right click) for showing colums can hide or show (disabled columns mean are not in selected profil), if one or least has filter show menu item for clear all filter, if current collumn has filter show menu item for clear this filter, and show current profil if exists

  • View profil context menu (right click + shift) view all columns with associated profil (translate by converter if exists)

  • Select profil context menu (right click + ctrl) for selected profil, if a profil is already set you have a menu item for clear this (selected profil is checked and disabled)

Texts

Many texts are used for translation in

filter editors

context menus


ColumnsTextHelper is made for this, set in ListView with

Properties Usage Desciption
ClearAllFilterText Context Menu for define text in normal context menu for clear all filter (in picture = effacer tous les filtres) [default = »Clear all filter »]
ClearFilterText Context Menu for define text in normal context menu for clear current filter (in picture = effacer ce filtre) [default = »Clear filter »]
ClearProfilText Context Menu for define text in selected profil context menu (in picure  = Clear selected profil) [default = »Clear selected profil »]
ProfilText Context Menu for define text before in normal context menu when profil is set (in picure = selected profil) [default = »Profil »]
EnumNoneText Filter for define text in filter for All checker (in picture = tous selectionner)  [default = »None view »]
EnumAllText Filter for define text in filter for None checker (in picture = tous deselectionner) [default = »All view »]

see MainWindowProfil.xaml for sample

Static Acess

For better acces you can use static command for

  • ClearSortCommand for clear current sorting

  • ClearAllFilterCommand

see MainWindowProfil.xaml for sample

and you can acess to profils but it’s more complex because you can get the ColumnsManager from ListView

see MainWindowBase.cs for sample (region PROFILS) and see MainWindowProfil.xaml for binding

overall you must have get  ColumnsManger from ListView in Constructor after loading

and after add adapter for Profils and SelectedProfil

for syncronize profil to reality (raise SelectedProfil for wrapper) use