在数据模板中调用情节提要

本文关键字:用情 调用 数据 | 更新日期: 2023-09-27 18:36:29

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

不存在用于解析名称"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>

调用故事板没有问题。但出于某种原因,即使情节提要位于 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 >