2

I have refer the image using relative path reference ("pack://application:,,,/Images/LoadingBlocks.gif") as mentioned. But image not able to loaded while running the application.

if i give the absolute image path, which working fine. that is

("C:\Users\Documents\Visual Studio 2015\Projects\WpfApplication2\WpfApplication2\Images\LoadingBlocks.gif)

or

("....\Images\LoadingBlocks.gif")

Please find my code snippet and sample then suggest your opinion for refer the image from the solution itself.

 <toolkit:BusyIndicator Name="BusyIndicator" Loaded="BusyIndicator_Loaded" DisplayAfter="0" IsBusy="False">
        <toolkit:BusyIndicator.BusyContentTemplate>
            <DataTemplate>
                <StackPanel Height="100" Width="100" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <MediaElement MediaEnded="myGif_MediaEnded" UnloadedBehavior="Manual" Source="pack://application:,,,/Images/LoadingBlocks.gif"  LoadedBehavior="Play">
                        <MediaElement.OpacityMask>
                            <ImageBrush ImageSource="pack://application:,,,/Images/LoadingBlocks.gif"/>
                        </MediaElement.OpacityMask>
                    </MediaElement>
                </StackPanel>
            </DataTemplate>
        </toolkit:BusyIndicator.BusyContentTemplate>
        <toolkit:BusyIndicator.OverlayStyle>
            <Style TargetType="Rectangle">
                <Setter Property="Fill" Value="Transparent"/>
            </Style>
        </toolkit:BusyIndicator.OverlayStyle>
        <toolkit:BusyIndicator.ProgressBarStyle>
            <Style TargetType="ProgressBar">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>
        </toolkit:BusyIndicator.ProgressBarStyle>
        <toolkit:BusyIndicator.Background>
            <SolidColorBrush Color="Transparent"/>
        </toolkit:BusyIndicator.Background>

    </toolkit:BusyIndicator>

sample: https://ufile.io/zdm6r

or

https://github.com/mathikp/LoadingIndicatorSample

  • Did you add the image as a resource? – P.Manthe Nov 12 '18 at 08:16
  • As a note `..\Images\LoadingBlocks.gif` is a relative path, while `pack://application:,,,/Images/LoadingBlocks.gif` is a WPF Pack URI, and of course absolute. That said, what exactly isn't working? Does the MediaElement not show the GIF, or does the OpacityMask not work? – Clemens Nov 12 '18 at 08:18
  • @Clemens both media element and opacity mask not working (i.e. gif image not loading) if we given the image path as pack URI. so how to set image reference path using pack URI. I have attached sample can you please check it – Thirumurugan Loganathan Nov 12 '18 at 08:25
  • Make sure the image file is located in a folder called Images in your Visual Studio project, and that its Build Action is set to Resource. – Clemens Nov 12 '18 at 08:26
  • @Clemens I have set build action as Resource and also image placed in that mentioned(Images folder) location. But not working – Thirumurugan Loganathan Nov 12 '18 at 08:28
  • @P.Manthe yes i have added image as Resource. – Thirumurugan Loganathan Nov 12 '18 at 09:24
  • Did you try to include the Assemblyname like: pack://application:,,, **/WpfApplication2;component** /Images/LoadingBlocks.gif – Daniel W. Nov 12 '18 at 12:44
  • @DanielW. Yes, I have tried that also. But not worked for me. I have resolved that issue by using gif animated behavior of WPFAnimatedGif assembly. instead of media element control. Thanks for your suggestion. – Thirumurugan Loganathan Nov 14 '18 at 11:30

0 Answers0