Autor Beitrag
C#
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 561
Erhaltene Danke: 65

Windows 10, Kubuntu, Android
Visual Studio 2017, C#, C++/CLI, C++/CX, C++, F#, R, Python
BeitragVerfasst: Fr 03.10.14 18:56 
Guten Abend - schon wieder :D

Da ich mich gerade von 0 auf 100 durch WPF bzw. XAML prügle, kann es sein, dass heute noch des öfteren Fragen von mir kommen.

Mein Problem diesmal:
Ich habe einen eigenen Style für Fenster erstellt (TargetType=Window). In diesem Style habe ich eine Animation mittels Storyboard. Dabei möchte ich (wie schon in meinem Post letzte Stunde) das Fenster ausfahren (Animtaion beim Öffnen), indem ich die Width-Eigenschaft ändere.
Wie kann ich innerhalb des Style den Endwert der Animation (DoubleAnimation.To) auf die Width-Eigenschaft des Fensters legen, dass diesen Style benutzt?

Ich hoffe man versteht die Frage :mrgreen:

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
  <Style BasedOn="{StaticResource {x:Type Window}}" x:Key="MenuWindowStyle" TargetType="Window" >
           <Setter Property="Window.AllowsTransparency" Value="True" />
           <Setter Property="Window.Background" Value="Transparent" />
           <Setter Property="Window.WindowStyle" Value="None" />
          
           <Style.Triggers>
                <EventTrigger RoutedEvent="Window.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation From="0" To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Window.Width), Mode=OneTime}" Storyboard.TargetProperty="(Window.Width)" Duration="0:0:0.5" />                                
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Style.Triggers>
        </Style>


So sieht der Style bis jetzt aus.

_________________
Der längste Typ-Name im .NET-Framework ist: ListViewVirtualItemsSelectionRangeChangedEventHandler
C# Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 561
Erhaltene Danke: 65

Windows 10, Kubuntu, Android
Visual Studio 2017, C#, C++/CLI, C++/CX, C++, F#, R, Python
BeitragVerfasst: Sa 04.10.14 17:10 
Niemand eine Idee / Link / Tipp? TemplatedParent ist ja eigentlich dafür gedacht!?!? :gruebel:

_________________
Der längste Typ-Name im .NET-Framework ist: ListViewVirtualItemsSelectionRangeChangedEventHandler
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4798
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 04.10.14 20:06 
Hallo,

ich habe mal im Internet nach "WPF DoubleAnimation.To Binding" gesucht und da scheinen ein paar Tricks nötig:
Binding Animation To and From Properties
WPF animation: binding to the “To” attribute of storyboard animation
WPF animation: binding to the “To” attribute of storyboard animation. (selbe Frage wie oben, aber anderes Forum)
How to bind to Animation To and FROM properties

Für diesen Beitrag haben gedankt: C#
C# Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 561
Erhaltene Danke: 65

Windows 10, Kubuntu, Android
Visual Studio 2017, C#, C++/CLI, C++/CX, C++, F#, R, Python
BeitragVerfasst: So 05.10.14 20:29 
Danke. Ich habe jetzt ein kleinen Workaround mithilfe des 2. Links gemacht. Ich hätte gerne direkt das Fenster animiert, aber so muss ich noch ein Grid dazwischen bauen damit es geht.

_________________
Der längste Typ-Name im .NET-Framework ist: ListViewVirtualItemsSelectionRangeChangedEventHandler