How to access application object in Silverlight class library? - silverlight

Suppose my solution have two project:
myApp: silverlight application project: the default application App
MyLib: silverlight class library project
then in code for those controls in Mylib, how to access the application object App?

Application.Current should do you right, box as necessary((MyAppClass)Application.Current).something

Related

How to cast from Windows.UI.Xaml.UIElement to System.Windows.Controls.UIElement

I'm trying to create a new UI for an app I developed for the Windows Store using the Windows Runtime API. This new client is going to be a WPF Desktop App. I'm trying to reuse as much code as I can but I'm facing several issues.
Fortunately there's a way to use WinRT in a WPF Desktop app (see this and this)
Now I'm blocked by the following issue:
The MediaCapture class has a method to start the preview of a device, after I've started the preview I can create a CaptureElement to display the preview.
CaptureElement is part of Windows.UI.Xaml.Controls and cannot be used in containers from System.Windows.Controls in which the WPF UI is built.
Am I going anywhere with this approach? what would you recommend? How can I display the preview of a device in the WPF app?
Thanks in advance
CaptureElement can't be used in desktop applications - the documentation says "[Windows Store apps only]". In general - the UI controls from WPF and WinRT/XAML can't be used outside of their respective domains (desktop/immersive UI). In a WPF app you need to use WPF controls - e.g. DirectShow for camera capture,

Silverlight 4 business application themes

We are starting a new SilverLight 4 Business Application project and are looking for theme. All we can find on the web are Navigation Application themes, which when applied to business application project, don't work. Most even have compilation errors.
Is there a place on the web to get theme specifically for that project or is there a way to translate navigation application theme into business application theme?
Thank you
Finally got around finding some.
Here goes :
http://gallery.expression.microsoft.com/en-us/site/search?f[0].Type=RootCategory&f[0].Value=themes&f[0].Text=Themes&f[1].Type=Tag&f[1].Value=RIAServices
Repair RIA Service using below link that issue/error will be solved.
http://download.microsoft.com/download/2/4/1/241B26FF-EC1E-41FE-A782-E669C28A0A00/RiaServices.msi
There are application themes for Silverlight 4 templates at Microsoft Download Center.

WPF Web application: How to embed in ASP.NET page?

I am trying to bulid a WPF web application.I have 2 projects in the solution .One is of type WPF web application and another is of type ASP.NET web application where i need to embed the WPF stuff.The XAML file runs file when i set startup project as the WPF web app project.How can i add/embed this into the Default.aspx of my ASP.NET Web app project ?
You are creating what is known as a XBAP (XAML Browser Application).
Follow these deployment instructions from MSDN:
WPF XAML Browser Applications Overview

How to access web application class into silverlight application

I am beginner in silverlight..I have created a silverlight project. When a new silverlight project is created it is automatically creating a silverlight application and one web application. I have added a class in both applications. Now I want to access a method of web application class into silverlight application class. Is it possible? I have tried to add web application reference to silverlight but VS is not allowing. Is there any another way to do??
What you need is called WCF. A really simple tutorial that should get you going is found here: How to call WCF methods from Silverlight controls
Fundementally WCF allows the silverlight client to make method calls on a class instance hosted on the web site.
Yes it is possible, but not in the normal way. A Silverlight assembly can only reference another Silverlight assembly (this is a limitation of VS2008, i don't know if it has been changed in VS2010).
What you need to do is add an existing file to your Silverlight project, when the file browse dialog opens you navigate to the class file you want to reuse, but instead of just clicking the Add button, click on the little down arrow on the button and choose Add as link - now the file will "exist" in both projects and can be used in both.
If you are going to do this repeatedly though, you will want to move those shared class files out into a separate assembly, do a project reference from your web app, and have the equivalent Silverlight class library mirroring it (sharing the files as links), and then project reference that Silverlight class library from your Silverlight app.

TestPage.aspx in silverlight

I am a beginner in silverlight. I want to know what is TestPage.aspx and TestPage.html in silverlight. Actually i have google it but din't get enough information. Can any one give me answer??
TestPage.aspx and TestPage.html are the pages which will host your Silverlight content. As you might know, Silverlight is just a project (not a web application) and needs a page that can host it.
These pages are created by default and help you to test your XAML content during your development, which you can later remove from your project.
TestPage.html is dynamically generated by the Silverlight application as part of the Debug process. If you take a look at the Debug tab for the application properties you will see an option to Dynamically generate a test page. If this is selected then you TestPage.html is created in the /Bin/Debug folder of your Silverlight application.
A better solution is to create a web application in the same solution as your Silverlight application then in the properties for the web application go to the Silverlight Applications tab and add your existing Silverlight app to the web project. Also make sure that the Silverlight checkbox is ticked in the Debuggers section of the Web tab of your web application.

Resources