KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am creating a simple custom control extending from toggle button that allows the user to specify checked and unchecked content directly in XAML. It works well but it is based on a trigger, and I don't know how to define the trigger except in a style. If I define the style, then I lose anything set outside of the custom control. What I would like to be able to do is just append this trigger to any existing style set elsewhere on the control. Here's the XAML for the style/trigger. <ToggleButton.Style> <Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource {x:Type ToggleButton}}"> <Setter Property="Content" Value="{Binding RelativeSource={RelativeSource Self}, Path=UncheckedContent}" /> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Content" Value="{Binding RelativeSource={RelativeSource Self}, Path=CheckedContent}" /> </Trigger> </Style.Triggers> </Style> </ToggleButton.Style> I tried inheriting the style via the BasedOn with a default type but it won't work if the custom control has an explicit style set by its parent. I also considered EventTriggers but I do not believe there would be an event to initialize the control. Thanks for any help anyone can offer. :)
Tags (comma-separated)
Save Edits
Cancel