Answer the question
In order to leave comments, you need to log in
How to move a variable to another page?
You need to transfer the variable to another page and the user too.
private void Button_Click(object sender, RoutedEventArgs e)
{
int i = 0;
if (FirstButton.IsChecked == true)
{
i = i + 2;
}
else if (SecondButton.IsChecked == true)
{
i = i + 1;
}
}
Answer the question
In order to leave comments, you need to log in
Here's an example for you. Create an instance common to the entire application, store only the data you need in it and call it as needed
public class DataContext
{
private static readonly object Lock = new object();
private static DataContext _ctx;
private static SQLiteAsyncConnection _database;
private static SQLiteAsyncConnection _userDatabase;
public static DataContext Instance
{
get
{
lock (Lock)
{
if (_ctx != null) return _ctx;
var filePathOnPlatform = GetFilePathOnPlatform(Settings.DataBaseName);
var userDb = GetFilePathOnPlatform(Settings.UserDatabaseName);
_ctx = new DataContext(filePathOnPlatform, userDb);
return _ctx;
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question