C#C
C#2y ago
Elio

Custom ToggleButon WPF

https://paste.mod.gg/siztgxijeavn/1

Hello, i'm trying to make my own togglebutton because i want it to have the property IscheckedLeft that allow me to easily switch the side of the checked value of my button. I've almost done it but i can't find a way to change my storyboard depends of IscheckedLeft. Basically i would like to
Set this if IscheckedLeft = false
<ThicknessAnimation
    Storyboard.TargetName="Thumb"
    Storyboard.TargetProperty="Margin"
    To="0 0 39 0"
    Duration="0:0:0.2" />

and Set this if IscheckedLeft = true
<ThicknessAnimation
    Storyboard.TargetName="Thumb"
    Storyboard.TargetProperty="Margin"
    To="39 0 0 0"
    Duration="0:0:0.2" />

My problem there is if i use a converter the following error is triggered "Cannot freeze this Storyboard timeline tree for use across threads".
Have you any idea how i could do this ?
Was this page helpful?