forked from hjam40/Camera.MAUI
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Hello
a View should show a QR-Code for transfering some informations to an other device
the first await Shell.Current.GoToAsync(nameof(SettingsView), true); works perfect
the second call after going back to the MainView with await Shell.Current.GoToAsync("..");
ends in a System.ObjectDisposedException: 'Cannot access a closed Stream.'
After removing the cv:BarcodeImage no problems comes up.
Changing Settings from Singelton to Transitions do not change the behaviour
here some Codesnippets out of the Project
MauiProgram.cs
builder.Services.AddSingleton<MainViewModel>();
builder.Services.AddSingleton<MainView>();
builder.Services.AddSingleton<SettingsViewModel>();
builder.Services.AddSingleton<SettingsView>();
MainViewModel.cs
[RelayCommand]
public async Task GoToSettings()
{
await Shell.Current.GoToAsync(nameof(SettingsView), true);
}
SettingsView.xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:cv="clr-namespace:Camera.MAUI;assembly=Camera.MAUI"
x:Class="AnteRoomAppointmentsApp.Views.SettingsView"
xmlns:models="clr-namespace:VirtualWaitLib.Models;assembly=VirtualWaitLib"
xmlns:viewmodel="clr-namespace:AnteRoomAppointmentsApp.ViewModels"
x:DataType="viewmodel:SettingsViewModel"
Title="SettingsView">
<VerticalStackLayout>
<Grid RowDefinitions="*">
<Grid RowDefinitions="50,500,30,50,*" ColumnDefinitions="*,*">
<!-- some other stuff ->
<cv:BarcodeImage Grid.Row="1" Grid.Column="0" x:Name="barcodeImage" Aspect="AspectFit"
WidthRequest="400" HeightRequest="400"
BarcodeWidth="380" BarcodeHeight="380" BarcodeMargin="5"
BarcodeBackground="White" BarcodeForeground="Black"
BarcodeFormat="QR_CODE" Barcode="{Binding BarCode}" />
</Grid>
</Grid>
</VerticalStackLayout>
</ContentPage>
SettingsViewModel.cs
[ObservableProperty]
string barCode = string.Empty;
public SettingsViewModel(VwzService vwzService)
{
_vwzService = vwzService;
Title = "Einstellungen";
//initialize data
Barcode tempBarCode = new Barcode();
tempBarCode.Id = "a Gui Id saved in SecureStore";
tempBarCode.Text = "some text";
tempBarCode.Name = "a Name";
BarCode = JsonConvert.SerializeObject(tempBarCode);
}
[RelayCommand]
async Task GoToPreviousView()
{
await Shell.Current.GoToAsync(".."); // back to MainPage
}
I hope this was all relevant stuff
does anyone have an idear maybe I'm doing some wrong
and I hope my english is not to bad
Metadata
Metadata
Assignees
Labels
No labels