【问题标题】:WPF:C#: The name "Interaction or eventtrigger or contolstroyboardaction" does not exist in the namespace " "WPF:C#: 名称“Interaction or eventtrigger or contolstroyboardaction”在命名空间“”中不存在
【发布时间】:2016-04-04 05:23:55
【问题描述】:

这是我的代码,我已经搜索了 stackoverflow 中给出的所有解决方案或答案,但没有帮助我。 以前发生此错误时,我只是构建它并开始工作,但每次它给我不同部分的相同错误。我已经搜索了所有可能的解决方案,但没有帮助我。

<Window 
   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:mc = "http://schemas.openxmlformats.org/markup-compatibility/2006" 
   xmlns:local = "clr-namespace:WPFBehaviors" 
   xmlns:i = "http://schemas.microsoft.com/expression/2010/interactivity" 
   xmlns:ei = "http://schemas.microsoft.com/expression/2010/interactions" 
   x:Class = "WPFBehaviors.MainWindow" 
   mc:Ignorable = "d" Title = "MainWindow" Height = "350" Width = "604">
    <Window.Resources>
        <Storyboard x:Key="Storyboard1" RepeatBehavior="Forever" AutoReverse="True">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="301.524" />
                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="2.909" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty= "(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-0.485" />
                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ContentControl.Content)" Storyboard.TargetName="button">
                <DiscreteObjectKeyFrame KeyTime="0" Value="Play" />
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ContentControl.Content)" Storyboard.TargetName="button1">
                <DiscreteObjectKeyFrame KeyTime="0" Value="Stop" />
                <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="Stop" />
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource Storyboard1}" />
        </EventTrigger>
    </Window.Triggers>
    <Grid>
        <Ellipse x:Name="ellipse" Fill="#FFAAAAC5" HorizontalAlignment="Left" Height="50.901" Margin="49.324, 70.922,0,0" Stroke="Black" VerticalAlignment="Top" Width="73.684" RenderTransformOrigin="0.5,0.5">
            <Ellipse.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Ellipse.RenderTransform>
        </Ellipse>
        <Button x:Name = "button" Content = "Play" HorizontalAlignment = "Left" Height = "24.238"
         Margin = "63.867,0,0,92.953" VerticalAlignment = "Bottom" Width = "74.654">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName = "Click">
                    <ei:ControlStoryboardAction Storyboard = "{StaticResource Storyboard1}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

        <Button x:Name = "button1" Content = "Stop" HorizontalAlignment = "Left" Height = "24.239"
         Margin = "160.82,0,0,93.922" VerticalAlignment = "Bottom" Width = "75.138">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName = "Click">
                    <ei:ControlStoryboardAction ControlStoryboardOption = "Stop"
                  Storyboard = "{StaticResource Storyboard1}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </Grid>
</Window>

【问题讨论】:

  • 在提供的代码中提供有关此错误发生位置的更多详细信息,并从代码中删除不适用于该问题的项目。您的问题已标记为 C#。你也有 C# 代码吗?
  • 杰拉德·塞克斯顿,感谢您的回复,
  • 但是C#没有代码,全部在wpf中完成,<...><....>

标签: c# .net wpf xaml


【解决方案1】:

对于使用此 XAML 的所有项目,您可以检查参考 Microsoft.Expression.InteractionsSystem.Windows.Interactivity(添加引用时请注意框架版本!)

【讨论】:

    猜你喜欢
    • 2014-01-11
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多