gpt4 book ai didi

c# - 在 DataTemplate 中调用 Storyboard

转载 作者:行者123 更新时间:2023-11-30 22:12:48 24 4
gpt4 key购买 nike

我的代码不断出现我无法弄清楚的错误。

No applicable name scope exists to resolve the name 'gridCallLog'.

<DataTemplate x:Key="ContentDetail">
<DataTemplate.Resources>
<Storyboard x:Key="StoryCallLogOn">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="gridCallLog">
<EasingThicknessKeyFrame KeyTime="0" Value="0,0,10,23.04"/>
<EasingThicknessKeyFrame KeyTime="0:0:0.6" Value="0,0,10,200"/>
</ThicknessAnimationUsingKeyFrames>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="borderCallLog">
<EasingThicknessKeyFrame KeyTime="0" Value="0,402,10,23.04"/>
<EasingThicknessKeyFrame KeyTime="0:0:0.6" Value="0,225,10,23.04"/>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</DataTemplate.Resources>
<StackPanel Orientation="Horizontal" Height="500" >
<Border Margin="10,5,0,10" BorderBrush="Transparent" CornerRadius="3" BorderThickness="1" Width="1050">
<StackPanel Margin="5,5,9,5" Orientation="Horizontal">
<dx:DXTabControl Width="850" Margin="5,5,0,0">
<dx:DXTabItem Header="Call Log">
<StackPanel>
<dxg:GridControl x:Name="gridCallLog" Height="400" ItemsSource="{Binding ElementName=MainStack,Path=DataContext.CallLog}"
dx:ThemeManager.ThemeName="Office2010Blue" Margin="0,0,10,0" SelectedItem="{Binding ElementName=MainStack,Path=DataContext.SelectedCallLog,UpdateSourceTrigger=PropertyChanged}" >
<dxg:GridControl.Columns >


<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<command:EventToCommand Command="{Binding ElementName=MainStack,Path=DataContext.CallLogOnCommand}" />
</i:EventTrigger>
<ei:DataTrigger Binding="{Binding ElementName=MainStack,Path=DataContext.CallLogOn, Mode=OneWay}" Value="ON">
<ei:ControlStoryboardAction Storyboard="{StaticResource StoryCallLogOn}" ControlStoryboardOption="Play"/>
</ei:DataTrigger>

Storyboard被调用没有问题。但出于某种原因,即使 Storyboard位于 DataTemplate.Resources 中,它也看不到名为 gridCallLog 的 GridControl。任何指针将不胜感激地接受。斯科特

最佳答案

您应该将资源添加到 DataTemplate 内的控件之一,而不是 DataTemplate 本身:

<DataTemplate x:Key="ContentDetail">
<StackPanel Orientation="Horizontal" Height="500" >
<StackPanel.Resources>
<Storyboard x:Key="StoryCallLogOn">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="gridCallLog">
<EasingThicknessKeyFrame KeyTime="0" Value="0,0,10,23.04"/>
<EasingThicknessKeyFrame KeyTime="0:0:0.6" Value="0,0,10,200"/>
</ThicknessAnimationUsingKeyFrames>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="borderCallLog">
<EasingThicknessKeyFrame KeyTime="0" Value="0,402,10,23.04"/>
<EasingThicknessKeyFrame KeyTime="0:0:0.6" Value="0,225,10,23.04"/>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</StackPanel.Resources>
<Border Margin="10,5,0,10" BorderBrush="Transparent" CornerRadius="3" BorderThickness="1" Width="1050">
<StackPanel Margin="5,5,9,5" Orientation="Horizontal">
<dx:DXTabControl Width="850" Margin="5,5,0,0">
<dx:DXTabItem Header="Call Log">
<StackPanel>
<dxg:GridControl x:Name="gridCallLog" Height="400" ItemsSource="{Binding ElementName=MainStack,Path=DataContext.CallLog}"
dx:ThemeManager.ThemeName="Office2010Blue" Margin="0,0,10,0" SelectedItem="{Binding ElementName=MainStack,Path=DataContext.SelectedCallLog,UpdateSourceTrigger=PropertyChanged}" >
<dxg:GridControl.Columns >

关于c# - 在 DataTemplate 中调用 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19522427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com