none
多个grid嵌套中控件的访问问题 c# RRS feed

  • 问题

  • 我要访问名为 testgrid 中的 myStoryboard 应该如何调用? myStoryboard.Begin() 这样调用的会出错,提示找不到myStoryboard。我是新手

    <Grid x:Name="my_grid" Margin="8,34,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="783" Height="438" Canvas.ZIndex="1" >
                    <FlipView x:Name="FlipView5Horizontal" Width="783" Height="438" BorderThickness="0" Style="{StaticResource FlipViewStyle1}" SelectionChanged="FlipView5Horizontal_SelectionChanged" Margin="0,0,0,0" >
                        <FlipView.ItemTemplate>
                            <DataTemplate>
                                <Grid x:Name="grid_2" Width="783" Height="438" HorizontalAlignment="Left" VerticalAlignment="Top" >
                                    <TextBlock x:Name="m_textblockUpdateTime" HorizontalAlignment="Left" Margin="10,3,0,0" TextWrapping="Wrap" Text="{Binding UpdateDate}" VerticalAlignment="Top" Width="400" Height="46" FontFamily="Microsoft YaHei" FontSize="22" Padding="0,8,0,0" />
                                    <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Width="783" Height="371" Margin="0,67,0,0" >
                                        <Grid.Background>
                                            <ImageBrush ImageSource="WeatherImages/weather_bg.png" Stretch="Uniform"/>
                                        </Grid.Background>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="447"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid x:Name="testgrid" Grid.Column="0" HorizontalAlignment="Left" Height="371" Margin="0" VerticalAlignment="Top" Width="447">
                                            <StackPanel>
                                                 <StackPanel.Resources>
                                                <!-- Animates the rectangle's opacity. -->
                                                   <Storyboard x:Name="myStoryboard">
                                              <DoubleAnimation
                                                          Storyboard.TargetName="m_imageWeather"
                                                          Storyboard.TargetProperty="Opacity"
                                                          From="0.0" To="1.0" Duration="0:0:1.2"
                                                          AutoReverse="False" />
                                                </Storyboard>
                                                 </StackPanel.Resources>                                     
                                             <Image x:Name="m_imageWeather" HorizontalAlignment="Left" VerticalAlignment="Top" Source="{Binding Image}"/>
                                            </StackPanel>
                                            
                                            <TextBlock x:Name="m_textblockData" HorizontalAlignment="Left" Margin="25,81,0,0" TextWrapping="Wrap" Text="{Binding Date}" VerticalAlignment="Top" Height="35" Width="200" FontSize="30"/>
                                            <TextBlock x:Name="m_textblockCityPinYin" HorizontalAlignment="Left" Margin="23,28,0,0" TextWrapping="Wrap" Text="{Binding City}" VerticalAlignment="Top" Width="271" Height="47" FontSize="30" Padding="0,5,0,0"/>
                                            <TextBlock x:Name="m_textblockTempleRange" HorizontalAlignment="Left" Margin="303,195,0,0" TextWrapping="Wrap" Text="{Binding Temperature}" VerticalAlignment="Top" Width="138" Height="35" FontSize="30"/>
                                            <TextBlock x:Name="m_textblockWeatherState" HorizontalAlignment="Left" Margin="25,298,0,0" TextWrapping="Wrap" Text="{Binding Statement}" VerticalAlignment="Top" Width="242" Height="35" FontSize="30"/>
                                        </Grid>
                                        
                                    </Grid>
                                </Grid>
                            </DataTemplate>
                        </FlipView.ItemTemplate>
                    </FlipView>
                </Grid>
        

    2012年7月3日 4:26

答案

全部回复