as easy as it sounds,
How can I use the themes provided in SL SDk 4.0 into WPF project??
It should be easy!! Am I missing something?
While Silverlight and WPF are related they are not identical. Each has namespaces, classes and methods that don't exist in the other.
Simply copying the Silverlight xaml into your WPF project and fixing the compile errors is one approach, but I wouldn't recommend it. There are differences, like Triggers for example, that have no direct equivalent.
Related
Is Silverlight a subset of WPF? If i learn WPF then can i say i know Silverlight too?
Silverlight is similar to WPF, and actually started out as WPF/E (WPF Everywhere) but at some point, it became a separate implementation and it is not directly compatible with WPF.
That said, most of the techniques and classes that you would learn in WPF will have a Silverlight variant. One primary exception being the 3D visualization facilities in WPF are not available in Silverlight.
Silverlight is still coded in a Silverlight-specific .NET run-time (a slimmer version than the full .NET run-time) and you still use XAML to describe your presentations.
It should also be noted that Silverlight does have built-in restrictions with accessing resources on the machine it is running on. For example, Silverlight applications can not access the registry. There are enhancements in Silverlight though that do allow for "out of browser" applications which can be given full-trust privileges.
The one big difference between Silverlight and WPF is the CLR (Common Language Runtime) and that Silverlight is Sandboxed, so you don't get alot of functionality you can get with WPF.
If you know WPF XAML and Model-View type aspects of programming styles with e.g Dependency propertys then you will find it quite easy to use Silverlight.
One big thing with Silverlight is that you cant reference C# non silverlight classes, you must use these types of classes via WCF.
Just curious I heard this somewhere... I doubt it is true...
You can't do it directly, but you can create a WPF project and add links to the Silverlight files.
If you don't use Silverlight-specific code, you'll have a WPF application.
Forgive me for being a little naive perhaps, but it seems that System.Windows.Controls.DataVisualization.Charting has vanished from VS2010, and blend 4. I'm trying to make a bar graph with a line overlayed, but can't even get started because I can't find the appropriate controls.
I know I could use an external graphing package, but I'd like to try the inbuilt controls first.
You mention Blend so I assume that you are refering to the WPF/Silverlight chart controls.
The System.Windows.Controls.DataVisualization.Charting namespace is part of the WPF Toolkit. You will have to download this toolkit and reference it from your project.
The question has been clarified to indicate it is about WPF controls. The answer below refers to the Winforms and Asp.net chart controls. I'm leaving it here in case other people find it useful.
The original MS Chart controls were never part of the framework. They are an separate project.
You can download them here.
There is also more info on their project page.
There is an addon to the IDE, (here), but it's for VS2008, I don't know if it will work with 2010. I would assume they are going to update it at some point, but there doesn't seem to be any information on when that will happen.
I stand corrected, .Net 4.0 apparently now has built in chart controls. You shouldn't need to install anything. You'll need to make sure you are targeting framework 4.0.
When i added the silverlight dll in the wpf application , i got the following exception.
Could not load file or assembly "System.Core, Version=2.0.5.0". The located assembly's manifest definition does not match the
assembly reference.
This is happening only in VS 2010 professional Beta 2.
You cannot use Silverlight directly in a WPF application, as they do not use the same version of the .NET Framework, thus the error message
Could you give some more details on your scenario ?
If you have a WPF app, you have more than what Silverlight can give to you.
If you are building a solution with multiple products, and one is WPF for the desktop, one is Silverlight for the Web, you need to create 2 different projects in VS.
Take a look at the source tree here:
http://expressionblend.codeplex.com/
Specifically, the Expression.Samples.Interactivity.Design branch.
This shows a few examples of how to put in property editors for use with Blend. I'm not sure if the same concept is transportable to the Cider design surface, but heck, Blend is nicer for pure XAML editing anyways. :)
Is it possible to develop against Silverlight and WPF using the same source code? Maybe using some #define blocks where it is necessary.
Theoretically it should be doable. It's not a big problem for the code. However, you'll have to be very careful with XAML and use only the intersecting subset of WPF and SL (1), as there's no #if/#endif for XAML.
(1) Contrary to the common belief, SL is not a proper subset of WPF. It has some features that WPF does not have, though these are being worked on.
Incidentally, PRISM (the composite application block from patterns and practices) now supports Silverlight and there's a C9 video with a quick sample on using code in both WPF and Silverlight.
I think if you stick to MV-V-VM (or something along those lines) then a lot of your backend code will be reusable, but the XAML itself might need to be forked if you want a full on "rich" experience, unless you are willing to use the VSM beta for WPF.
I have no experience on that but I have used a component that targets both WPF and Silverlight environment with the same code (there are only few differences).
The component is Chart from Visifire and it's Open Source
Maybe you can take a look into it
You can use Visual Studio file linking to include classes from WPF projects in Silverlight - but only if they don't do any UI or XAML based stuff (as this is where you will usually find inconsistencies between the two)...
So keep it to business logic etc.
Flashcards.Show application is a great example of this WPF/SL/WP7 code sharing and cross platform possibilities.
http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/03/03/flashcards-show-planning-a-cross-platform-solution.aspx
Concept of cross platform is pretty simple because everything works on .NET and a similar XAML binding system. My advice here is to invest more time on architecture of the app in terms of MVVM and other abstraction to segregate the platform dependencies. So that a major percentage of the code can be re-used across while some of the XAML might need to rewrite depends on the visual complexity of the app in different platforms.