public SettingPage() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.navigationHelper.LoadState += navigationHelper_LoadState; Messenger.Default.Register <string>(this, "ChangeUIBrushImage", async str => { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpeg"); openPicker.FileTypeFilter.Add(".png"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); var size = stream.Size; byte[] bytes = new byte[size]; var reader = new DataReader(stream.GetInputStreamAt(0)); await reader.LoadAsync((uint)size); reader.ReadBytes(bytes); var uiBrush = new UIBrush(); uiBrush.IsImageEnable = true; uiBrush.UIImage = bytes; if (str == "MainBackground") { viewModel.Setting.AppTheme.MainBackground = uiBrush; } if (str == "BottomTweetBarBackground") { viewModel.Setting.AppTheme.BottomTweetBarBackground = uiBrush; } if (str == "BottomAppBarBackground") { viewModel.Setting.AppTheme.BottomAppBarBackground = uiBrush; } if (str == "TopAppBarBackground") { viewModel.Setting.AppTheme.TopAppBarBackground = uiBrush; } if (str == "SettingsFlyoutBackground") { viewModel.Setting.AppTheme.SettingsFlyoutBackground = uiBrush; } } }); }
public object ConvertBack(object value, Type targetType, object parameter, string language) { if (value != null) { var c = value as SolidColorBrush; UIBrush brush = new UIBrush(); brush.IsImageEnable = false; brush.UIColor = c.Color; return(brush); } else { return(new UIBrush()); } }