Microsoft Interactions is not recognized in XAML - wpf

My goal:
I want to use Interaction Triggers in that way:
<i:Interaction.Triggers>
Therefore I opened the Nuget and installed this:
After this the two references (Microsoft.Expression.Interactions and System.Windows.Interactivity) were added to my project. The path of those points to the package directory (Blend.Interactivity.Wpf.1.0.1340.0) in my project folder.
The problem:
The namespace is not recognized by Visual Studio. I tried:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
Intelisense is not recognizing any elements inside the i-Tag.
The .Net version of the project is 4.5.2.
I tried to remove and reinstall the package.
Any ideas what went wrong here?

Related

How to add IdentityModel reference

I am working through IS quickstart and having trouble adding IdentityModel to the Client project. I installed the NuGet package through VS.Net and it seemed to be successful but after that, the assembly does not show from the reference list. What am I missing here? Do I need to browse the file system to find the dll? If so, where?
When you add the IdentityServer4 NuGet package, it has a dependency on IdentityModel. So it is already added and that's you don't see it.
You can see its dependencies here
And in Visual Studio if you drill down the Dependencies -> Packages -> IdentityServer4 node

How to get WPF XAML Designer to play nicely with IValidatableObject from NET Standard 2.0 libraries?

Background:
using Visual Studio 2017 v15.4 (no ReSharper or any weird extensions)
Repro solution includes 2 projects:
WPF project: .NET 4.6.1, using NuGet PackageReference format
Class library: NET Standard 2.0
Both projects have the System.ComponentModel.Annotations NuGet package installed.
Problem
After upgrading my WPF project's NuGet format from the old packages.config to the new PackageReference, I started experiencing design-time errors:
Or sometimes the harsher flavor:
To start with, the following ViewModel code works fine:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
public class MainWindowViewModel
{
public ValClass MyProp => new ValClass();
}
public class ValClass : IValidatableObject
{
//Implementation stuff
}
However, if I then define an identical class in my NET Standard project, and include that as a type in my ViewModel, it produces the error.
Comparing an F12 on the IValidatableObject of these 2 classes:
The WPF version:
#region Assembly System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\System.ComponentModel.DataAnnotations.dll
#endregion
The NET Standard 2.0 version:
#region Assembly System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Users\a0110\.nuget\packages\system.componentmodel.annotations\4.4.0\ref\netstandard2.0\System.ComponentModel.Annotations.dll
#endregion
It's clear that the same type and namespace are defined in assemblies with different names--not just assembly versions.
How can I get the XAML Designer to successfully locate whatever assembly is required to use IValidatableObject?
Things I have Tried
Installing VS v15.5 preview and targeting the WPF project to .NET 4.7 (also 15.5 preview 2 and 3, .NET 4.7.1)
Adding the old System.ComponentModel.DataAnnotations reference to the WPF project (with and without the NuGet version)
reverting back to packages.config format (this didn't actually succeed; it appears that I'm stuck with PackageReference!)
grabbing a copy of the System.ComponentModel.Annotations.dll from the project's output folder and referencing it directly (VS would not let me do this)
adding a bindingRedirect to my App.config
adding <DependsOnNETStandard>True</DependsOnNETStandard> to the .csproj
adding <DependsOnNETStandard>netstandard2.0</DependsOnNETStandard> to .csproj
adding <_HasReferenceToSystemRuntime>true</_HasReferenceToSystemRuntime> to .csproj
adding the NETStandard.Library NuGet package to the WPF project
Update
For anyone else who is plagued by this issue, I have found a workaround:
Locate the System.ComponentModel.Annotations.dll on your hard drive that your NET Standard project uses for IValidatableObject. Copy it to a location within your project.
Uninstall the System.ComponentModel.Annotations NuGet package from your solution
Give your NET Standard project a direct reference to DLL you copied
Give your WPF project a reference to the standard assembly System.ComponentModel.DataAnnotations
Upgrade your WPF project to target .NET 4.7.1
Compile. Your WPF design-time should be free from this error.
.

Is it possible to use WinRT XAML Toolkit with WPF?

I try to install using Visual Studio Package Manager Console and got this error:
Install failed. Rolling back... Install-Package : Could not install
package 'WinRTXamlToolkit.Controls.Gauge 1.6.1.3'. You are trying to
install this package into a project that targets
'.NETFramework,Version=v4.5', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author. At line:1
char:1
+ Install-Package WinRTXamlToolkit.Controls.Gau
Not as a NuGet package, I think you'd need a WPF Toolkit (of some sort).
WinRT XAML Toolkit is based on CoreCLR, not on the full .NET 4.5.
You can use the source code with very minor modifications though (mostly in namespaces). It depends on which part of the toolkit you need.
Check out the source at https://github.com/xyzzer/WinRTXamlToolkit

VS2010 Silverlight project add reference defaults to GAC

I have the SL Control toolkit installed on my machine and I have added a reference to the toolkit DLL (System.Windows.Controls.Toolkit.dll)
I like to have all my external dependencies in a lib folder under the SL project, so I copied over the DLL from the installation dir of the control toolkit to the lib folder, but if I try to add reference to the DLL from this location, VS is still picking up the reference from the installation dir.
What gives?
I ran across this problem everyday. The easy (it feels that way after some time) solution is to unload the project (right click>Unload Project) then right click again en select Edit. Find a reference that is point to another assembly in your lib folder, copy that Xml element and change the 'Hint' path to your assembly.
It will look something like:
<ItemGroup>
<Reference Include="Ninject">
<HintPath>..\..\Ninject.dll</HintPath>
</Reference>
<Reference Include="System" />
<!-- other references removed for breviti-->
</ItemGroup>
The installed DLLs are always searched first, even if you add the DLL by browsing. The path in the properties window (for your added reference) would have shown the "installed" version instead immediately after adding the reference to your copy.
A build machine would not have the toolkit installed. You could uninstall the toolkit and organise the DLLs yourself if you really need that sort of behaviour.

What happened to the prism project linker in Visual Studio 2010?

How do I share files between WPF and Silverlight projects in Visual Studio 2010?
You can download Project Linker for Visual Studio 2010 in the Extension Manager. Just search for "Project Linker". It works perfectly!
The project linker download can be found here at the bottom of the page in the "Files in this Download" section:
http://www.microsoft.com/downloads/details.aspx?familyid=fa07e1ce-ca3f-4b9b-a21b-e3fa10d013dd&displaylang=en
And just in case you were also asking about its usage, here is a link to the usage information:
http://msdn.microsoft.com/en-us/library/dd458870.aspx
It doesn't appear to have been released as a self installer for VS2010. However, the code does appear to have been updated to allow the plugin to run in VS2010.
Have a look at this discusson thread. About two thirds of the way down the tread, it gets to the point where they give that link and discuss the steps for making it work. Here is the link to the source code updated for VS2010.
The steps to use the code to generate an installer that will work for you are (ripped from the linked thread):
open solution in vs2010
compile as release
add a new VSIX project (template located under c#>Extensibility).
In the VSIX project you need to add two "content" items
- a "VS Package type" as the output of the project linker project,
- a "Custom Extension" Type - as a file and browse to the compiled project linker helper dll
HTH

Resources