M
M
Michael2015-05-02 19:43:37
WPF
Michael, 2015-05-02 19:43:37

How in EventTrigger, in animation, set the color from the application settings?

I created my own button in style. All colors are stored in the application settings (and the user can change them, which is why they are stored in the settings). The base color of the button is set like this (the code is simplified):

<Style TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Rectangle x:Name="RectangleBackground"
                             Fill="{Binding ColorButtonBackground, 
                             Source={x:Static res:Settings.Default}}"/>
                    <ControlTemplate.Triggers>
                    ...
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

But in the animation, you cannot set the color from the application settings:
<EventTrigger RoutedEvent="MouseEnter">
  <BeginStoryboard>
    <Storyboard>
      <ColorAnimation Storyboard.TargetName="RectangleBackground"
                Storyboard.TargetProperty="(RectangleBackground.Background).(SolidColorBrush.Color)"
                To="{Binding ColorButtonBackgroundHighlighted,
                Source={x:Static res:Settings.Default}}"/><!--Error-->
    </Storyboard>
    </BeginStoryboard>
</EventTrigger>

The question is how to set the color from the application settings?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question