A display may contain many user configurable settings. These display settings can be edited from the user interface and are stored with the display in the workbook. All display properties are shown in a property grid; the infrastructure described in the following sections detail how to populate the property grid with your own items.
View
The following snippet of XAML shows how the display properties view may look:
<UserControl x:Class="Atlas10DisplayPlugin.Views.NewDisplayPropertiesView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:propertyGrid="clr-namespace:MAT.Atlas.Platform.Presentation.Wpf.UserControls.PropertyGrid;assembly=MAT.Atlas.Platform.Presentation.Wpf" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" x:ClassModifier="internal"> <Grid> <propertyGrid:AtlasPropertyGrid x:Name="PropertyGrid" SelectedObject="{Binding}" PropertyGridType="Display" /> </Grid> </UserControl>
View Model
The following snippet of code shows how the view model for display properties may look:
[TypeConverter(typeof(PropertySorter))] internal sealed class NewDisplayPropertiesViewModel : DisplayPropertiesViewModelBase, INewDisplayPropertiesViewModel { // Stores the default value of the property. private bool defaultTitleBarVisible; public NewDisplayPropertiesViewModel( IDisplayPropertyService displayPropertyService, IWorkbookService workbookService) : base(displayPropertyService, workbookService) { } // The category, name and description (located in resource files) determine // where and how in the property grid the property will appear. [LocalizedCategory("DisplayPropertyCategoryGeneral", typeof(Resources))] [LocalizedDisplayName("DisplayPropertyTitleBarVisibleName", typeof(Resources))] [LocalizedDescription("DisplayPropertyTitleBarVisibleDescription", typeof(Resources))] [Editor(typeof(GlobalSelectableTypeEditor), typeof(UITypeEditor))] public bool TitleBarVisible { get { return this.ViewModel.TitleBarVisible; } set { // Only set the property if the view model is active. if (this.TitleBarVisible == value || this.ViewModel.IsActive == false) { return; } this.ViewModel.TitleBarVisible = value; this.NotifyPropertyChanged(); } } private INewDisplayViewModel ViewModel { get { return (INewDisplayViewModel)this.DisplayViewModel; } } protected override void Reset() { // Reset values to their default. base.Reset(); this.TitleBarVisible = this.defaultTitleBarVisible; } protected override void SyncDefaultValues() { // Synchronise property defaults with view model values. base.SyncDefaultValues(); this.defaultTitleBarVisible = this.ViewModel.TitleBarVisible; } }
Comments
0 comments
Please sign in to leave a comment.