tags:

views:

270

answers:

0

I want to host a Flash animation in a WPF project. It is okay. But the problem is it shows in a tabcontrol. When I click second tabitem I want the flash animation to start. It gives this error:

Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

My codes are as follows:

C# code.

    private void Maintab_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (this.Maintab.SelectedIndex == 2)//Second tabitem
        {
            System.Windows.Forms.Integration.

            WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();

            xShockwaveFlashObjects.  //What is this ?????

            AxShockwaveFlash axShockwaveFlash1 = new AxShockwaveFlashObjects.AxShockwaveFlash();
            host.Child = axShockwaveFlash1;
            this.FlashGrid.Children.Add(host);
            string swfPath = System.Environment.CurrentDirectory;
            swfPath +=@"\cell.swf";
            axShockwaveFlash1.Movie = swfPath;
        }
    }

XAML:

    <TabControl
      Style="{DynamicResource GelTabControl}"
      Margin="0,0,8,36"
      x:Name="Maintab"
      SelectionChanged="Maintab_SelectionChanged" >

        <TabItem
          x:Name="Actions"
          Header="Actions"
          Style="{DynamicResource GelTabItem2}"
          TabIndex="1">
        </TabItem>

        <TabItem
          Header="Rapid Note"
          Style="{DynamicResource GelTabItem2}"
          TabIndex="2" >
            <Grid x:Name="FlashGrid">
            </Grid>
        </TabItem>

    <!-- Something is missing here !?  -->

Thanks in advance.