Hello,
Welcome to Microsoft Q&A!
Please check the following code, and update your check method with double type parameter, and use newValue to replace Number Value property.
private void NumberBox_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
{
Task.Run(() =>
{
autoResetEvent.WaitOne();
check(newValue);
});
}
}
private async void check(double roomvalue)
{
StorageFolder folderSP = await KnownFolders.DocumentsLibrary.GetFolderAsync("Św. Puszcza App");
try { StorageFolder folderDATE = await folderSP.GetFolderAsync(date_string); }
catch { Windows.Storage.StorageFolder folderDATE = await folderSP.CreateFolderAsync(date_string, CreationCollisionOption.ReplaceExisting); }
StorageFolder newfolderDATE = await folderSP.GetFolderAsync(date_string);
try { StorageFile file = await newfolderDATE.GetFileAsync(roomvalue + ".dat"); }
catch { Windows.Storage.StorageFile file = await newfolderDATE.CreateFileAsync(roomvalue + ".dat", CreationCollisionOption.ReplaceExisting); }
Windows.Storage.StorageFile fileROOM = await newfoldeRDATE.GetFileAsync(roomvalue + ".dat");
string text = await Windows.Storage.FileIO.ReadTextAsync(filerROOM);
}
private double newValue;
private double oldValue = -1;
AutoResetEvent autoResetEvent = new AutoResetEvent(false);
private void MyBox_ValueChanged(Microsoft.UI.Xaml.Controls.NumberBox sender, Microsoft.UI.Xaml.Controls.NumberBoxValueChangedEventArgs args)
{
if (args.NewValue != double.NaN)
{
newValue = args.NewValue;
autoResetEvent.Set();
}
}
Xaml
<uicontrols:NumberBox
Height="44"
KeyDown="NumberBox_KeyDown"
ValueChanged="MyBox_ValueChanged"
Value="NaN" />
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.