I would like to use the WPF and Silverlight toolkit's TreeView control, but have it be in the same xaml file that I share between 2 projects as a link. In silverlight, the class is in the System.Windows.Controls.dll and in WPF it is in PresentationFramework.dll. So for my xaml namespace, they need to be declared differently which causes problems. Is there anyway to make this work?
Asked
Active
Viewed 204 times
3 Answers
0
AFAIK, you won't be able to do this, Silverlight assemblies and .NET assemblies are not compatible with each other (although the XAML might be similar, but the namespaces, as you have noticed, are different).

casperOne
- 73,706
- 19
- 184
- 253
0
Did you tried using the Conditional Compilation symbol #if !SILVERLIGHT
.
Kindly check the following links.
http://msdn.microsoft.com/en-us/magazine/ee321573.aspx
What is the best practice for compiling Silverlight and WPF in one project?

Community
- 1
- 1

Prince Ashitaka
- 8,623
- 12
- 48
- 71
-
I'm actually trying to share the same xaml file. Unfortunately, there isn't an easy way to do #if !SILVERLIGHT in xaml. – NotDan Jan 25 '11 at 15:18
-
If it is not a complex template try loading the template via code behind using the conditional compilations as mentioned above. HTH :) – Prince Ashitaka Jan 25 '11 at 17:35
0
I have written a blog article about sharing .xaml
files. The idea is to create a proxy control in your source code and use that control in .xaml
:
namespace UnifiedXaml
{
public class MyWrapPanel: WrapPanel { }
}
<UserControl x:Class="UnifiedXaml.TestControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ux="clr-namespace:UnifiedXaml">
<ux:MyWrapPanel></ux:MyWrapPanel>
</UserControl>

Lukas Cenovsky
- 5,476
- 2
- 31
- 39