Click here to Skip to main content
15,867,141 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Problems pausing and restarting animations in XAML Pin
Gerry Schmitz6-Jan-18 8:26
mveGerry Schmitz6-Jan-18 8:26 
GeneralRe: Problems pausing and restarting animations in XAML Pin
Kenneth Haugland6-Jan-18 8:41
mvaKenneth Haugland6-Jan-18 8:41 
GeneralRe: Problems pausing and restarting animations in XAML Pin
Gerry Schmitz6-Jan-18 8:51
mveGerry Schmitz6-Jan-18 8:51 
GeneralRe: Problems pausing and restarting animations in XAML Pin
Kenneth Haugland6-Jan-18 9:17
mvaKenneth Haugland6-Jan-18 9:17 
GeneralRe: Problems pausing and restarting animations in XAML Pin
Gerry Schmitz6-Jan-18 9:32
mveGerry Schmitz6-Jan-18 9:32 
QuestionWPF Pin
Bogadamidi3-Jan-18 16:20
Bogadamidi3-Jan-18 16:20 
AnswerRe: WPF Pin
Kenneth Haugland3-Jan-18 18:31
mvaKenneth Haugland3-Jan-18 18:31 
QuestionBegin a storyboard in a ControlTemplate Pin
Kenneth Haugland1-Jan-18 22:28
mvaKenneth Haugland1-Jan-18 22:28 
So I was reading the documentation about Prism 7: Composing the User Interface Using the Prism Library 5.0 for WPF[^] and downloaded the source code for the application here:
Prism for WPF Reference Implementation Code Sample in C# for Visual Studio 2013[^]

I really liked the animated TabControl and thought I'd implement it based on that application. The trouble was that when I implemented it on a different new solution I ran into a problem with the animated Template.
<SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#8C8E94"/>

    <Style TargetType="Controls:AnimatedTabControl">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Padding" Value="4,4,4,4"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
        <Setter Property="Background" Value="#F9F9F9"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:AnimatedTabControl">

                    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Border Height="30" Margin="10,0,10,10"  HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto" Grid.Row="1" CornerRadius="12,12,12,12" Background="{TemplateBinding Background}" BorderThickness="2,2,2,2" BorderBrush="#FFFFFFFF">
                            <TabPanel x:Name="HeaderPanel" HorizontalAlignment="Center" VerticalAlignment="Center" IsItemsHost="true" Grid.Column="0" Grid.Row="0" KeyboardNavigation.TabIndex="1"/>
                        </Border>

                        <Grid Grid.Row="1" Margin="0,40,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Viewport3D x:Name="vp3D" Visibility="Hidden" Width="Auto" Height="Auto">
                                <Viewport3D.Camera>
                                    <PerspectiveCamera x:Name="camera" Position="0,0,0.5" LookDirection="0,0,-1" FieldOfView="90" />
                                </Viewport3D.Camera>
                                <Viewport3D.Children>
                                    <ModelVisual3D>
                                        <ModelVisual3D.Content>
                                            <Model3DGroup>
                                                <DirectionalLight Color="#444" Direction="0,0,-1" />
                                                <AmbientLight Color="#BBB" />
                                            </Model3DGroup>
                                        </ModelVisual3D.Content>
                                    </ModelVisual3D>
                                    <ModelVisual3D>
                                        <ModelVisual3D.Content>
                                            <GeometryModel3D>
                                                <GeometryModel3D.Geometry>
                                                    <MeshGeometry3D  TriangleIndices="0,1,2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" Positions="-0.5,-0.5,0 0.5,-0.5,0 0.5,0.5,0 -0.5,0.5,0" />
                                                </GeometryModel3D.Geometry>
                                                <GeometryModel3D.Material>
                                                    <DiffuseMaterial>
                                                        <DiffuseMaterial.Brush>
                                                            <VisualBrush Visual="{Binding ElementName=BorderIn}" Stretch="Uniform" />
                                                        </DiffuseMaterial.Brush>
                                                    </DiffuseMaterial>
                                                </GeometryModel3D.Material>
                                                <GeometryModel3D.BackMaterial>
                                                    <DiffuseMaterial>
                                                        <DiffuseMaterial.Brush>
                                                            <VisualBrush Visual="{Binding ElementName=BorderIn}" Stretch="Uniform">
                                                                <VisualBrush.RelativeTransform>
                                                                    <ScaleTransform ScaleX="-1" CenterX="0.5" />
                                                                </VisualBrush.RelativeTransform>
                                                            </VisualBrush>
                                                        </DiffuseMaterial.Brush>
                                                    </DiffuseMaterial>
                                                </GeometryModel3D.BackMaterial>
                                                <GeometryModel3D.Transform>
                                                    <RotateTransform3D>
                                                        <RotateTransform3D.Rotation>
                                                            <AxisAngleRotation3D x:Name="rotate" Axis="0,3,0" Angle="0" />
                                                        </RotateTransform3D.Rotation>
                                                    </RotateTransform3D>
                                                </GeometryModel3D.Transform>
                                            </GeometryModel3D>
                                        </ModelVisual3D.Content>
                                    </ModelVisual3D>
                                </Viewport3D.Children>
                            </Viewport3D>
                            <Border x:Name="BorderOut" VerticalAlignment="Stretch">
                                <Border x:Name="BorderIn" VerticalAlignment="Stretch" Background="#00000000" >
                                    <Grid>
                                        <Controls:RoundedBox Margin="10" />
                                        <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="20"/>
                                    </Grid>
                                </Border>
                            </Border>
                        </Grid>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="Controls:AnimatedTabControl.SelectionChanging">
                            <BeginStoryboard>
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="vp3D"  Storyboard.TargetProperty="Visibility">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
                                        <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="{x:Static Visibility.Hidden}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation To="0" Duration="0:0:0.05" Storyboard.TargetName="BorderOut" Storyboard.TargetProperty="Opacity" />
                                    <DoubleAnimation BeginTime="0:0:1.05" Duration="0:0:0.05" To="1" Storyboard.TargetName="BorderOut" Storyboard.TargetProperty="Opacity" />
                                    <Point3DAnimation To="0,0,1.1" From="0,0,0.5"  BeginTime="0:0:0.05" Duration="0:0:0.5" AutoReverse="True" DecelerationRatio="0.3"  Storyboard.TargetName="camera" 
                                            Storyboard.TargetProperty="(PerspectiveCamera.Position)" />
                                    <DoubleAnimation From="0" To="180" AccelerationRatio="0.3" DecelerationRatio="0.3" BeginTime="0:0:0.05" Duration="0:0:1"  Storyboard.TargetName="rotate" Storyboard.TargetProperty="Angle" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>


            </Setter.Value>
        </Setter>
    </Style>

It first complained that I could not find any of the TargetName's in the storyboard. I replaced the targetnames with a binding TargetName="{Binding Element=vp3D}" etc, so It now found the properties. However, that only resulted in a new error, namely that "Cannot freeze this Storyboard timeline tree for use across threads". I think I figured out why, or sort of why:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/9336022f-badb-4b40-a86c-a50ab1a64ba5/cannot-freeze-this-storyboard-timeline-tree-for-use-across-threads?forum=wpf

But I have no idea about what to do to fix the issue. I tried to define the storyboard as a Static resource, but the same error persisted. If I comment out the Storyboard code the TabControl works as expected. What am I missing here?
AnswerRe: Begin a storyboard in a ControlTemplate Pin
Pete O'Hanlon2-Jan-18 0:55
subeditorPete O'Hanlon2-Jan-18 0:55 
GeneralRe: Begin a storyboard in a ControlTemplate Pin
Kenneth Haugland2-Jan-18 3:35
mvaKenneth Haugland2-Jan-18 3:35 
GeneralRe: Begin a storyboard in a ControlTemplate Pin
Pete O'Hanlon2-Jan-18 4:38
subeditorPete O'Hanlon2-Jan-18 4:38 
AnswerRe: Begin a storyboard in a ControlTemplate Pin
Pete O'Hanlon2-Jan-18 6:11
subeditorPete O'Hanlon2-Jan-18 6:11 
GeneralRe: Begin a storyboard in a ControlTemplate Pin
Kenneth Haugland2-Jan-18 6:41
mvaKenneth Haugland2-Jan-18 6:41 
GeneralRe: Begin a storyboard in a ControlTemplate Pin
Pete O'Hanlon2-Jan-18 7:49
subeditorPete O'Hanlon2-Jan-18 7:49 
QuestionComboBoxEdit Control Pin
Kevin Marois21-Dec-17 6:09
professionalKevin Marois21-Dec-17 6:09 
AnswerRe: ComboBoxEdit Control Pin
Kenneth Haugland1-Jan-18 23:16
mvaKenneth Haugland1-Jan-18 23:16 
QuestionVB.Net/WPF/XAML "The video does not load via the executable." Pin
Member 1358548219-Dec-17 13:20
Member 1358548219-Dec-17 13:20 
AnswerRe: VB.Net/WPF/XAML "The video does not load via the executable." Pin
Pete O'Hanlon19-Dec-17 19:33
subeditorPete O'Hanlon19-Dec-17 19:33 
GeneralRe: VB.Net/WPF/XAML "The video does not load via the executable." Pin
Member 1358548219-Dec-17 22:42
Member 1358548219-Dec-17 22:42 
QuestionComboBox ItemTemplate Pin
Kevin Marois16-Dec-17 8:44
professionalKevin Marois16-Dec-17 8:44 
AnswerRe: ComboBox ItemTemplate Pin
Gerry Schmitz17-Dec-17 7:18
mveGerry Schmitz17-Dec-17 7:18 
GeneralRe: ComboBox ItemTemplate Pin
Kevin Marois17-Dec-17 8:14
professionalKevin Marois17-Dec-17 8:14 
GeneralRe: ComboBox ItemTemplate Pin
Gerry Schmitz17-Dec-17 8:30
mveGerry Schmitz17-Dec-17 8:30 
QuestionUsing Rx with MVVM pattern Pin
Kenneth Haugland16-Dec-17 0:40
mvaKenneth Haugland16-Dec-17 0:40 
AnswerRe: Using Rx with MVVM pattern Pin
Kenneth Haugland16-Dec-17 3:16
mvaKenneth Haugland16-Dec-17 3:16 

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.