Value syntax for DataTrigger

Hi,
I have some roller shutters and want to display the level via an icon. Therefore I have 10 icons for the levels for 0%, 10%, 20%, … etc.
Now I can create 100 DataTriggers to address the respective levels, but this can not be the way.
Under ‘value’ I included <2, <11, <21 etc. but this do not run.
What is the right syntax for the value field? Have some of you experience with it and share it with me?

You definitely do not need 100 DataTriggers to do this:) You can use the Regex (Regular Expression) option to create a single trigger that’ll run for a range of values. Regex can be a little complicated but fortunately there is a tool that can help. @Federico_S shared a link with us in the old forum to the Regex Numeric Range Generator. This is pretty nice. You just enter your Min & Max values & it’ll give you a Regular Expression that you can copy into the Designer.
http://gamon.webfactional.com/regexnumericrangegenerator/

Here are the values it generated for me when given your set of values. While it may not be absolutely necessary, I had the option Match Whole Line checked.

1-10 = ^([1-9]|10)$
11-20 = ^(1[1-9]|20)$
21-30 = ^(2[1-9]|30)$
31-40 = ^(3[1-9]|40)$
41-50 = ^(4[1-9]|50)$
51-60 = ^(5[1-9]|60)$
61-70 = ^(6[1-9]|70)$
71-80 = ^(7[1-9]|80)$
81-90 = ^(8[1-9]|90)$
91-100= ^(9[1-9]|100)$

image

For reference, here is the original post from Federico in the Google Group:
https://groups.google.com/d/msg/thehomeremote/SjGcamS9jSU/cJPLhN3tBwAJ

1 Like

Thank you for the support. I tried all variations of the generator, also your numbers. But unfortunately without any success. If I include e.g. a 46 for the level of 46% it runs. But if I include the generated expression for the range 41 - 50 ^(4[1-9]|50)$ the data triger do not work.
Do I something wrong?

Did you check the IsRegularExpression property in the Designer?

By default, regular expressions are not enabled. You need to enable them.

Does it look like this?

image

thank you very much, I could have thought of that myself.
Can I ask you something else? I have a lot of blinds at my house. Now I can copy the icon with the 10 data triggers and then replace the binding for all 10 data triggers. But this is very cumbersome. Is there a possibility to replace the binding for all data triggers at once?

No. Best thing to do would be use templates so you can reuse the same XAML file for all of your blinds. Both the DeviceBrowser & PageBrowser controls support templates.