Can't use WpfAnimatedGif nuget package [duplicate] - wpf

This question already has an answer here:
The namespace prefix "system" is not defined
(1 answer)
Closed 9 months ago.
I'm trying to make a WPF project that use nuget package of "WpfAnimatedGif" (https://github.com/XamlAnimatedGif/WpfAnimatedGif) in order to make a window background gif.
But for some reason, i can't use this package after i install it. I try to use namespaces of the package, for example:
<Image gif:ImageBehavior.AnimatedSource="Resources\animated.gif"
gif:ImageBehavior.AutoStart="True"
gif:ImageBehavior.RepeatBehavior="1"/>
but the visual studio show erros like:
"The namespace prefix "gif" is not defined."
What can i do to solve this problem?
thank you.
This is the XAML code:
<Window x:Class="TriviaGame.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TriviaGame"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Image gif:ImageBehavior.AnimatedSource="Resources\animated.gif"
gif:ImageBehavior.AutoStart="True"
gif:ImageBehavior.RepeatBehavior="1"/>
</Grid>

The namespace prefix it's complaining about is an xmlns. You're missing:
xmlns:gif="http://wpfanimatedgif.codeplex.com"
See the example code on github.
https://github.com/XamlAnimatedGif/WpfAnimatedGif

Related

"Live" data in XAML editor window in Visual Studio and running application

I am trying implementing an addin for SparxEA with the MVVM Light. One thing that I found interesting is seeing “live” data in a window as is mentioned in the course of MVVM Light. So, I would like to do the same. As I have Class Library project I can’t use App.XAML.
In XAML I have this code:
<Window x:Class="GoatJira.View.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GoatJira.View"
xmlns:viewmodel="clr-namespace:GoatJira.ViewModel"
mc:Ignorable="d"
Title="{Binding Path=AboutTitle}" Height="322.613" Width="573.608" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Initialized="Window_Initialized"
DataContext="{Binding Source={StaticResource ResourceKey=AboutData}}"
>
<Window.Resources>
<ResourceDictionary>
<viewmodel:AboutViewModel x:Key="AboutData"/>
</ResourceDictionary>
</Window.Resources>
…
This perfectly works within Visual Studio IDE. When I run the app and want to instantiate the window, I obtain this exception (translated from Czech): Source marked as AboutData was not found. Names of sources are case sensitive.
When I remove the 10th line with DataContext, I can’t see the bind data within the VS, on the other hand, application works fine when I assign the DataContext in code. My understanding is, that there is a way when it works in VS and in running app without changing anything.
Do you have any idea what I am doing wrong?
If needed, the whole code is at https://github.com/SlavekRydval/GoatJira.
What happens if you move the DataContext to after the resource section i.e.
<Window blah=for>
<Window.Resources>
<ResourceDictionary>
<viewmodel:AboutViewModel x:Key="AboutData"/>
</ResourceDictionary>
</Window.Resources>
<Window.DataContext>
<StaticResourceExtension ResourceKey="AboutData"/>
</Window.DataContext>

How to set title of DXRibbonWindow in its center

I'm using DXRibbonwindow like this:
<dxr:DXRibbonWindow x:Class="MyNameSpace.MyRibbonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxd="http://schemas.devexpress.com/winfx/2008/xaml/docking"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
SnapsToDevicePixels="True"
WindowStartupLocation="CenterScreen" WindowState="Maximized"
Title="title">
<Grid>
...
</Grid>
</dxr:DXRibbonWindow>
I want the title to be in the middle of the window's titlebar, but it doesn't, how can i make it? I'm using DevExpress 14.2.5 .
Override default control template using Visual Studio Blend or like it's explained here
I would recommend to use Blend see an example and the difference blend and VS editors
This problem occured in version 14.5 of DEVExpress, I upgrade its version to the newest 17.1 then the problem has been solved, thanks for the DevExpress developer.

Modern UI ClusteredBarChart Does Not Exist In XML Namespace

I am using Metro charts for creating charts, but when I add chart and debug it says:
Error: The tag 'ClusteredBarChart' does not exist in XML namespace
'clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart'.
Line 325 Position 22.
I have already added dll for WPF in reference and added name space as
xmlns:chart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart"
I have no clue why it is giving this error?
EDIT:
this is code for adding chart control
<chart:ClusteredBarChart x:Name="barchart1" ChartSubTitle="Population in millions" ChartTitle="Countries by population">
<chart:ClusteredBarChart.Series>
<chart:ChartSeries DisplayMember="Name" ItemsSource="{Binding Path=Populations}" SeriesTitle="World largest populations" ValueMember="Count" />
</chart:ClusteredBarChart.Series>
</chart:ClusteredBarChart>
If you use the DLL under the Binaries/WPF folder, despite the error message, it will still work. If you download and compile the source code and use the resulting DLL from your compilation, the error message goes away.
<Window x:Class="WpfApplication249.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:chart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart"
xmlns:local="clr-namespace:WpfApplication249"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MyViewModel/>
</Window.DataContext>
<Grid>
<chart:ClusteredBarChart x:Name="barchart1"
ChartSubTitle="Population in millions"
ChartTitle="Countries by population">
<chart:ClusteredBarChart.Series>
<chart:ChartSeries DisplayMember="Name"
ItemsSource="{Binding Path=Populations}"
SeriesTitle="World largest populations"
ValueMember="Count" />
</chart:ClusteredBarChart.Series>
</chart:ClusteredBarChart>
</Grid>

WPF DesignData not working

I have a MVVM WPF application with a simple ListView. The ViewModel currently just contains a List property. I added a DesignData/SampleData.xaml file, set its Build Action to "DesignData" and referenced it in the Window's XAML code
<Window x:Class="..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="..."
mc:Ignorable="d"
Title="MainWindow" Height="483" Width="932">
<Grid d:DataContext="{d:DesignData Source=./DesignData/SampleData.xaml}">
But nothing shows up in the designer and VS2010 just gives me the following warning:
The file './DesignData/SampleData.xaml' is not part of the project or its 'Build Action' is not set to 'Resource'.
No matter what the "Build Action" it still gives me the same warning.
SampleData.xaml:
<MainWindowViewModel xmlns="clr-namespace:..."
xmlns:local="clr-namespace:...">
<MainWindowViewModel.Orders>
<local:Order OrderId="1000654321"/>
</MainWindowViewModel.Orders>
</MainWindowViewModel>
Any ideas on how to fix that?
Edit:
Project structure
The DesignData path is wrong as I thought it was relative to the solution/project whereas it seems it is relative to the containing XAML file.

Inconsistency between XAML intellisense and compiler for a control

I am converting some Silverlight XAML into WPF. I currently have a user control (MyControl) that is trying to include a couple of other controls that are custom buttons (MyButton1) that are within the same assembly. I have the following XAML that compiles and works in SL:
MyButton1
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MyCompany.MyNamespace.MySubnamespace.MyButton1"
d:DesignWidth="640" d:DesignHeight="480">
...
</UserControl>
MyControl
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:somename="clr-namespace:MyCompany.MyNamespace.MySubnamespace;assembly=MyCompany.MyAssemblyName"
mc:Ignorable="d"
x:Class="MyCompany.MyNamespace.MySubnamespace.MyControl"
d:DesignWidth="640" d:DesignHeight="480">
<somename:MyButton1 />
</UserControl>
When I try to compile this code in WPF, I get the following error:
The tag 'MyButton1' does not exist in XML namespace 'clr-namespace:MyCompany.MyNamespace.MySubnamespace;assembly=MyCompany.MyAssemblyName.'
The weird thing is, if I comment out the <somename:MyButton1 /> line of code and compile and then type in <somename: IntelliSense gives me the option to autocomplete MyButton1. Which suggests that the control itself is in the assembly but for some reason it is not being seen when the MyControl XAML is being compiled.
For some context, I took the SL csproj file and made some modifications to it manually to make it a WPF csproj file. If there is a possibility that this caused this funkiness to happen, I'd be glad to share relevant portions of the project file.
Found the answer on an MSDN forum. Turns out that the assembly=MyCompany.MyAssemblyName line in my xmlns was screwing things up. Once I removed that line, I was able to reference the controls.
Related Link: http://social.msdn.microsoft.com/Forums/en/wpf/thread/807c9b80-81c7-4f75-aa2f-8427e17b1a90
To reference the current assembly you must not type its name but leave it blank, i.e. assembly=, the other option is of course to drop it completely. (MSDN -> Mapping to Current Assemblies)

Resources