Skip to content

Binding on Selector Style #6743

Answered by Tenjim
Tenjim asked this question in Q&A
Oct 15, 2021 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

The workaround I found is to use Tag property to contains binding enum value (in string format) and use a style selector with checking Tag property like this

<Style Selector="ListBox#lstBox[Tag=SuperUser] ListBoxItem">

EDIT :

as mentionned @maxkatz6 (Thanks Max) :

I added many classes on my control ListBox to make two different styles :

<ListBox x:name="lstBox" 
Classes.User="{Binding PersonViewModel.Users, Converter={ToBoolean}, ConverterParameter="{x:Static enums:Status.User}"}"
Classes.SuperUser="{Binding PersonViewModel.Users, Converter={ToBoolean}, ConverterParameter="{x:Static enums:Status.SuperUser}"}">

after that apply style with selector from a style :

<Style Selector="ListBox.U…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@Tenjim
Comment options

@workgroupengineering
Comment options

@Tenjim
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Tenjim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants