Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania bez odpowiedzi
Viewing all articles
Browse latest Browse all 21942

animacja WPF

$
0
0

Witam programistów,

Zacząłem się bawić WPF, w którym używam animacji. Jak najbardziej pokazuje mi się jak również "animuje". Problem w tym, że położenie do jakiego punktu ma się przemieścić jest niezależne od wielkości okna. Trzeci dzień próbuje aby ruch animacji dostosował się do rozmiaru okna, animacja była skalowalna. HELP

<Window x:Class="StacjaKolejowa5.View.Visualization"
       ...
        >

<Window.Resources>
        <viewmodel:TrainViewModel x:Key="ViewModel"/>
 </Window.Resources>

 <ItemsControl DataContext="{StaticResource ViewModel}" ItemsSource="{Binding Path=Sprites}" Grid.ColumnSpan="2">
                            <ItemsControl.ItemsPanel >
                                <ItemsPanelTemplate >
                                    <Canvas/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
</ItemsControl>

 

public static void MakeTrainMove(Train train,
                                       double fromX, double toX, double y)
        {
            Canvas.SetTop(train, y);
            Storyboard storyboard = new Storyboard();
            DoubleAnimation animation = new DoubleAnimation();
            Storyboard.SetTarget(animation, train);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Canvas.LeftProperty));
            animation.From = fromX;
            animation.To = toX;
            animation.Duration = TimeSpan.FromSeconds(3);
            animation.RepeatBehavior = RepeatBehavior.Forever;
            animation.AutoReverse = true;
            
            storyboard.Children.Add(animation);
            storyboard.Begin();
        }

 


Viewing all articles
Browse latest Browse all 21942

Trending Articles


TRX Antek AVT - 2310 ver 2,0


Автовишка HAULOTTE HA 16 SPX


POTANIACZ


Zrób Sam - rocznik 1985 [PDF] [PL]


Maxgear opinie


BMW E61 2.5d błąd 43E2 - klapa gasząca a DPF


Eveline ➤ Matowe pomadki Velvet Matt Lipstick 500, 506, 5007


Auta / Cars (2006) PLDUB.BRRip.480p.XviD.AC3-LTN / DUBBING PL


Peugeot 508 problem z elektroniką


AŚ Jelenia Góra