sawyer
sawyer

Reputation: 21

WP7: can I access items on mainpage.xaml from app.xaml.cs?

I want to preload some setting on mainpage.xaml but only app is launched one time. I know I should use Application_Launching event in app.xaml but How can I set first value of my textbox on mainpage.xaml? thanks.

Upvotes: 1

Views: 592

Answers (2)

sawyer
sawyer

Reputation: 21

I thought Isolatedstorage is like notepad of windowsphone where i can store some data but not initially values. maybe my explanation was very unclear. simply a sample, I want to set my datepicker initially take 1 day later than today. I did that first just like this

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {

        dtpDate.Value = DateTime.Now.AddDays(1);

    }

but then I realized if user tries to change datapickers value, it causes page loaded again and it takes inital value. secondly, I learnt I should use Application_Launching event in app.xaml but I couldnt figure out how to set this below from app.xaml

dtpDate.Value = DateTime.Now.AddDays(1);

thanks for your help

Upvotes: 0

Lukasz Madon
Lukasz Madon

Reputation: 15004

You can use IsolatedStorage for your textbox. Tombstoning sample

Upvotes: 1

Related Questions