private void Button_Clicked(object sender, EventArgs e) { try { IsVisible = false; ViewModel.Dispose(); listView.ItemsSource = null; ViewModel.WorkChanged -= SwitchButton; ViewModel = null; _popper(); } catch (Exception x) { App.Debug("Critical error!\nError: " + x.Message + "\nStacktrace: " + x.StackTrace); } }
public void Init(string folder, string customName, IReadOnlyList <Video> items, Action popper) { try { _popper = popper; _player = new Tools.AudioPlayer(); var previews = items.Select(v => new PreviewItem(v, _player)).ToList(); ViewModel = new PreviewViewModel(folder, customName, previews); BindingContext = ViewModel; ViewModel.WorkChanged += SwitchButton; listView.ItemsSource = ViewModel.Items; OnBindingContextChanged(); backButton.IsEnabled = true; } catch (Exception e) { App.Debug("Critical error!\nError: " + e.Message + "\nStacktrace: " + e.StackTrace); } }