Click here to Skip to main content
15,910,009 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Routed Event Args Null Pin
Richard Deeming28-Jun-21 22:34
mveRichard Deeming28-Jun-21 22:34 
QuestionHow to change background color in combobox in code behind? Pin
Cường Nguyễn Văn 202123-Jun-21 6:56
Cường Nguyễn Văn 202123-Jun-21 6:56 
QuestionMake textbox fill up and resizie Pin
Acuena21-Jun-21 20:59
Acuena21-Jun-21 20:59 
AnswerRe: Make textbox fill up and resizie Pin
Richard Deeming21-Jun-21 21:58
mveRichard Deeming21-Jun-21 21:58 
AnswerRe: Make textbox fill up and resizie Pin
Gerry Schmitz22-Jun-21 7:07
mveGerry Schmitz22-Jun-21 7:07 
Question[Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Oscar Tsai18-Jun-21 7:34
Oscar Tsai18-Jun-21 7:34 
AnswerRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Gerry Schmitz19-Jun-21 14:29
mveGerry Schmitz19-Jun-21 14:29 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Oscar Tsai20-Jun-21 3:20
Oscar Tsai20-Jun-21 3:20 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Gerry Schmitz20-Jun-21 6:01
mveGerry Schmitz20-Jun-21 6:01 
AnswerRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Richard Deeming20-Jun-21 23:37
mveRichard Deeming20-Jun-21 23:37 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Oscar Tsai21-Jun-21 4:10
Oscar Tsai21-Jun-21 4:10 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Oscar Tsai21-Jun-21 16:11
Oscar Tsai21-Jun-21 16:11 
AnswerRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
michaelbarb23-Sep-21 10:32
michaelbarb23-Sep-21 10:32 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Oscar Tsai13-Oct-21 15:14
Oscar Tsai13-Oct-21 15:14 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
michaelbarb14-Oct-21 12:38
michaelbarb14-Oct-21 12:38 
QuestionProblem Setting Focus Pin
Kevin Marois24-May-21 9:39
professionalKevin Marois24-May-21 9:39 
AnswerRe: Problem Setting Focus Pin
Richard Deeming24-May-21 21:56
mveRichard Deeming24-May-21 21:56 
QuestionImpossible to override a value in an animation located in a style? Pin
Mc_Topaz20-May-21 6:51
Mc_Topaz20-May-21 6:51 
I have a style FooStyle with some properties and an animation.
I have two other styles Bar1Style and Bar2Style which is based on the FooStyle and sets some properties. I would like to alter the the values in the animation for the Bar-styles.

In the animation I'm altering the buttons ScaleX and ScaleY values with the MouseIsOver trigger.
In the code bellow you notice the values FrameOneValue and FrameTwoValue.

XML
<Style TargetType="Button" x:Key="FooStyle">
    <Style.Resources>
        <system:Double x:Key="FrameOneValue">1.0</system:Double>
        <system:Double x:Key="FrameTwoValue">1.05</system:Double>
    </Style.Resources>
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="RenderTransformOrigin" Value="0.5 0.5" />
    <Setter Property="RenderTransform">
        <Setter.Value>
            <TransformGroup>
                <ScaleTransform/>
            </TransformGroup>
        </Setter.Value>
    </Setter>
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Trigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames 
                            Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameOneValue}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameTwoValue}"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames 
                            Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameOneValue}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameTwoValue}"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
            </Trigger.EnterActions>
            <Trigger.ExitActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames 
                            Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameTwoValue}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameOneValue}"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames 
                            Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameTwoValue}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameOneValue}"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
            </Trigger.ExitActions>
        </Trigger>
    </Style.Triggers>
</Style>
In the Bar1Style and Bar2Style styles I would like to alter the values for FrameOneValue and FrameTwoValue to suit these styles. As the XAML-code to setup for the animation is quite large I would like to have have the definition in the FooStyle.

The Bar1Style and Bar2Style might look like this:
XML
<Style TargetType="{x:Type Button}" x:Key="Bar1Style" BasedOn="{StaticResource FooStyle}">
    <Style.Resources>
        <system:Double x:Key="FrameOneValue">2.0</system:Double>
        <system:Double x:Key="FrameTwoValue">2.05</system:Double>
    </Style.Resources>
    <Setter Property="Background" Value="Blue" />
</Style>
XML
<Style TargetType="{x:Type Button}" x:Key="Bar2Style" BasedOn="{StaticResource FooStyle}">
    <Style.Resources>
        <system:Double x:Key="FrameOneValue">3.0</system:Double>
        <system:Double x:Key="FrameTwoValue">3.05</system:Double>
    </Style.Resources>
    <Setter Property="Background" Value="Red" />
</Style>
I would then use this like:
XML
<Window x:Class="Main.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:Main"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">

    <StackPanel Orientation="Vertical">
        <Button Content="btn1" Style="{DynamicResource FooStyle}" />
        <Button Content="btn2" Style="{DynamicResource Bar1Style}" />
        <Button Content="btn2" Style="{DynamicResource Bar2Style}" />
    </StackPanel>
</Window>
But this fails hard due to:
Cannot freeze this Storyboard timeline tree for use across threads
Which seems to be due to I have specified DynamicResource in the FooStyle.
Which means that I cannot specify values for an animation dynamically in the Bar1Style and Bar2Style styles Sigh | :sigh:

Is there some way to solve this?
It's very annoying to have an entire setup of the animation for each style. I just want to alter the values in the Bar-style.
AnswerRe: Impossible to override a value in an animation located in a style? Pin
Gerry Schmitz20-May-21 8:08
mveGerry Schmitz20-May-21 8:08 
QuestionApp Security Behavior Pin
Kevin Marois20-May-21 6:09
professionalKevin Marois20-May-21 6:09 
QuestionOverride a value in base style's resource Pin
Mc_Topaz20-May-21 2:45
Mc_Topaz20-May-21 2:45 
AnswerRe: Override a value in base style's resource Pin
Richard Deeming20-May-21 4:33
mveRichard Deeming20-May-21 4:33 
GeneralRe: Override a value in base style's resource Pin
Mc_Topaz20-May-21 6:00
Mc_Topaz20-May-21 6:00 
QuestionApply TextBlock Captions at Runtime Pin
Kevin Marois14-May-21 9:34
professionalKevin Marois14-May-21 9:34 
AnswerRe: Apply TextBlock Captions at Runtime Pin
Peter_in_278014-May-21 13:36
professionalPeter_in_278014-May-21 13:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.