Это мой код, xaml:
Код: Выделить всё
Код: Выделить всё
private bool _isPreviewVisible;
public bool IsPreviewVisible
{
get => _isPreviewVisible;
set
{
_isPreviewVisible = value;
OnPropertyChanged(nameof(IsPreviewVisible));
}
}
private bool _isDeleteButtonVisible;
public bool IsDeleteButtonVisible
{
get => _isDeleteButtonVisible;
set
{
_isDeleteButtonVisible = value;
OnPropertyChanged(nameof(IsDeleteButtonVisible));
}
}
public void UpdateDeleteButtonVisibility()
{
// Check if gallery has any images
IsDeleteButtonVisible = Images.Any(); // _images is the ObservableCollection used for the gallery
}
public void UpdatePreviewImage()
{
IsPreviewVisible = false;
/*string folderPath = Path.Combine(FileSystem.AppDataDirectory, "Downloads");
var imagePaths = Directory.GetFiles(folderPath, "*.jpg").ToList();
if (imagePaths.Count > 0)
{
PreviewImageSource = imagePaths.First(); // Set the latest image
IsPreviewVisible = true;
}
else
{
PreviewImageSource = null; // Clear the image source
IsPreviewVisible = false; // Hide the button
}*/
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ui-net-for
Мобильная версия