Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access custom property created in App.xaml.cs in Silverlight 4

I have created my own custom property in app.xaml.cs file I require to access this property in one of my viewmodel. When i try to access via Application object it does not show up. Can anyone help me with this.

Regards

like image 253
MAQ Avatar asked Jan 24 '12 07:01

MAQ


People also ask

What are XAML CS files?

xaml. cs is the code-behind file where you write the business logic instead of inline code in . xaml. This provides more flexiblity of code separation and code readability.

What is MainPage XAML CS?

xaml contains the user interface, and MainPage. xaml. cs contains the logic, often called the code-behind. Listing 1.1 shows the initial contents of MainPage.

What is XAML CS in C#?

xaml. cs is the code-behind page for MainPage. xaml. It's where you add your app logic and event handlers. Together these two files define a new class called MainPage , which inherits from Page, in the HelloWorld namespace.


1 Answers

Use Application.Current to access custom property you have crated.

var currentApp =  Application.Current as App;
currentApp.YourPropertyName = "WhateverYouWant";

Read this article on MSDN with example on how to do it.

like image 186
Maheep Avatar answered Oct 04 '22 15:10

Maheep