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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With