zdesperowana utworzyłam nowy projekt, gdzie nie namieszałam w nazwach, niestety nadal występuje ten sam błąd, podam kod ponownie:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Media.Animation;
namespace App3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Random random = new Random();
public MainWindow()
{
InitializeComponent();
}
private void startButtoN_Click(object sender, RoutedEventArgs e)
{
AddEnemy();
}
private void AddEnemy()
{
ContentControl enemy = new ContentControl();
enemy.Template = Resources["EnemyTemplate"] as ControlTemplate;
AnimateEnemy(enemy, 0, playArea.ActualWidth - 100, "(Canvas.Left");
AnimateEnemy(enemy, random.Next((int)playArea.ActualHeight - 100),
random.Next((int)playArea.ActualHeight - 100), "(Canvas.Top)");
playArea.Children.Add(enemy);
}
private void AnimateEnemy(ContentControl enemy, double from, double to, string propertyToAnimate)
{
Storyboard storyboard = new Storyboard() { AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever };
DoubleAnimation animation = new DoubleAnimation()
{
From = from,
To = to,
Duration = new Duration(TimeSpan.FromSeconds(random.Next(4, 6)))
};
Storyboard.SetTarget(animation, enemy);
Storyboard.SetTargetProperty(animation, propertyToAnimate); //55
storyboard.Children.Add(animation);
storyboard.Begin();
}
}
}
oraz
<Page
x:Class="App3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Foreground>
<SolidColorBrush Color="{ThemeResource SystemAltLowColor}"/>
</Page.Foreground>
<Page.BorderBrush>
<SolidColorBrush Color="{ThemeResource SystemAltMediumColor}"/>
</Page.BorderBrush>
<Page.Background>
<SolidColorBrush Color="{ThemeResource SystemAltLowColor}"/>
</Page.Background>
<Grid>
<Grid.Background>
<SolidColorBrush Color="{ThemeResource SystemBaseHighColor}"/>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="160"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="160"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Grid Grid.ColumnSpan="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
<Button x:Name="startButton" Content="Start" Grid.Row="2" BorderThickness="0" RequestedTheme="Light" Foreground="White" BorderBrush="{x:Null}" Click="startButton_Click" Margin="0,0,0,16" VerticalAlignment="Bottom">
<Button.Background>
<SolidColorBrush Color="{ThemeResource SystemBaseMediumColor}"/>
</Button.Background>
</Button>
<ProgressBar Grid.Column="1" Grid.Row="2" Foreground="#FFF23876" Height="20">
<ProgressBar.Background>
<SolidColorBrush Color="{ThemeResource SystemAltMediumColor}"/>
</ProgressBar.Background>
</ProgressBar>
<StackPanel Grid.Column="2" Orientation="Vertical" Grid.Row="2">
<TextBlock x:Name="Avoid_them_all_" Margin="0" TextWrapping="Wrap" FontSize="10" Style="{StaticResource SubheaderTextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock.Foreground>
<SolidColorBrush Color="{ThemeResource SystemAltMediumColor}"/>
</TextBlock.Foreground>
<Run Text="Avoid them "/>
<Run Text="a"/>
<Run Text="l"/>
<Run Text="l"/>
<Run Text="!"/>
<LineBreak/>
<Run/>
</TextBlock>
<ContentControl Content="ContentControl" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Black" Foreground="White">
<ContentControl.Resources>
<ControlTemplate x:Key="EnemyTemplate" TargetType="ContentControl">
<Grid>
<Ellipse Fill="#FFF23876" Height="5" Width="5"/>
</Grid>
</ControlTemplate>
</ContentControl.Resources>
<ContentControl.Template>
<StaticResource ResourceKey="EnemyTemplate"/>
</ContentControl.Template>
</ContentControl>
</StackPanel>
<Canvas x:Name="playArea" Grid.Row="1" Margin="0" Grid.ColumnSpan="3" Background="White">
<Ellipse x:Name="human" Width="10" Height="10">
<Ellipse.Fill>
<SolidColorBrush Color="{ThemeResource SystemAltLowColor}"/>
</Ellipse.Fill>
</Ellipse>
<Ellipse x:Name="target" Width="13" Margin="0" Height="13" Canvas.Left="10" Canvas.Top="4">
<Ellipse.Stroke>
<SolidColorBrush Color="{ThemeResource SystemAltMediumColor}"/>
</Ellipse.Stroke>
</Ellipse>
<TextBlock x:Name="gameOverText" TextWrapping="Wrap" Text="Game Over" Foreground="#33000000" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Center" Canvas.Left="261" Canvas.Top="10"/>
</Canvas>
</Grid>
</Page>
podam również link do PrtScr zaznaczonych przez VS błedów:
https://1drv.ms/i/s!AmtYxsShGfjphSLjsvfrIp6kydIC
bardzo dziękuję za ogromne chęci Z Waszej strony, przykro mi, że nie potrafię bardziej sprecyzować problemu (wynika to z mojej niewiedzy). Bardzo chcę się nauczyć programować... nie zdawałam sobie sprawy, że to takie czasochłonne... ale nie chcę się poddać:)