1

I downloaded WPFAnimatedGiff.dll from codeplex. And here is the problem: I'm trying to implement the giff inside of tab item. The giff is actually a circular progress bar, so I'm trying to simulate loading process of the tab item similar to google chrome progress bar. I inserted the image, and it is visible in designer, but it does not show up when I run my application. Also when I insert image somewhere else in grid, it does show up. Here is the code:

<Window x:Class="WPFHotel.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WPFHotel"
    xmlns:data="clr-namespace:WPFHotel.Database"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:gif="http://wpfanimatedgif.codeplex.com" />


 <TabItem Tag="PB1" Header="Rezervacije" Name="Reservations" BorderBrush="Black" FontFamily="Times New Roman" FontWeight="Bold" FontSize="14">
            <TabItem.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">                            
                        <TextBlock Text="Rezervacije" Margin="5,2,0,0" />
                        <Image gif:ImageBehavior.AnimatedSource="Images/468.gif" Stretch="None" />                           

                    </StackPanel>                        
                </DataTemplate>
            </TabItem.HeaderTemplate>
</TabItem>

Tried to google for the solution but could not find anything useful, so I hope some one can help me here. Edit: Just to mention that when I insert the image like this:

<Image Source="Images/CircleBar.gif" />

It is shown when application runs but there is no spin/animation.

4

3 回答 3

5

有两种解决方案

  1. 在 StackPanel 的任何网格中创建一个 UserControl 并添加 XAML
  2. 设计一个WindowsForm,在其上添加动画控件,然后在WPF代码中调用它,但是记住你必须设置那个动画控件的两个属性,一个是它的StartPosition,另一个是TopMOST = True
于 2014-01-06T04:48:07.797 回答
0

您可以考虑为此使用另一个控件

http://huydinhpham.blogspot.com/2011/07/wpf-loading-panel.html

这是一个代码http://sites.google.com/site/huyphamproject/Home/LoadingPanelSample.zip

请注意,您可以根据需要对其进行简化。

我希望这将帮助您摆脱 WPF 中的 GIF。

于 2013-08-05T17:54:36.750 回答
0

您可以只拍摄 gif 中的所有照片,然后让这些照片分别闪现。这可能需要一些时间,但它是一种不需要太多编码知识的万无一失的方法。

于 2013-08-05T18:00:51.950 回答