Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2015 17:12
Show Gist options
  • Save anonymous/0ac9c753b0f42709a502 to your computer and use it in GitHub Desktop.
Save anonymous/0ac9c753b0f42709a502 to your computer and use it in GitHub Desktop.
ComboBox Background & Diff Display
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WPFTest.Models
{
/// <summary>
/// DataTemplateSelector class for displaying a different value in the combobox selection versus the dropdown items.
/// </summary>
public class ComboBoxItemTemplateSelector : DataTemplateSelector
{
/// <summary>
/// The DropDown DataTemplate.
/// </summary>
public DataTemplate DropDownTemplate { get; set; }
/// <summary>
/// The Selected DataTemplate.
/// </summary>
public DataTemplate SelectedTemplate { get; set; }
/// <summary>
/// Select the template to use for the indicated container.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="container">The dependency object determining the template.</param>
/// <returns>The correct template for the ComboBoxItem.</returns>
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
ComboBoxItem comboBoxItem = this.GetVisualParent<ComboBoxItem>(container);
if (comboBoxItem != null)
{
return this.DropDownTemplate;
}
return this.SelectedTemplate;
}
/// <summary>
/// Get the visual parent of the indicated object.
/// </summary>
/// <typeparam name="T">The desired return type.</typeparam>
/// <param name="childObject">The child object.</param>
/// <returns>The child/parent object of type T.</returns>
public T GetVisualParent<T>(object childObject) where T : Visual
{
DependencyObject child = childObject as DependencyObject;
while (child != null && !(child is T))
{
child = VisualTreeHelper.GetParent(child);
}
return child as T;
}
}
}
using System;
using Microsoft.Practices.Prism.Mvvm;
namespace WPFTest.Models
{
public class Entry : BindableBase
{
private bool selected;
private int id;
private string type;
private string description;
private DateTime effective;
private DateTime lastdate;
private string lastuser;
public bool Selected
{
get { return this.selected; }
set { SetProperty(ref this.selected, value); }
}
public int ID
{
get { return this.id; }
set { SetProperty(ref this.id, value); }
}
public string Type
{
get { return this.type; }
set { SetProperty(ref this.type, value); }
}
public string Description
{
get { return this.description; }
set { SetProperty(ref this.description, value); }
}
public DateTime EffectiveDate
{
get { return this.effective; }
set { SetProperty(ref this.effective, value); }
}
public DateTime LastChangeTime
{
get { return this.lastdate; }
set { SetProperty(ref this.lastdate, value); }
}
public string LastChangeUser
{
get { return this.lastuser; }
set { SetProperty(ref this.lastuser, value); }
}
}
}
<Window x:Class="WPFTest.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpfTest="clr-namespace:WPFTest.ViewModels"
xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Mvvm;assembly=Microsoft.Practices.Prism.Mvvm.Desktop"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFTest.Models"
mc:Ignorable="d" Title="WPF Test" Height="221.256" Width="605"
d:DataContext="{d:DesignInstance wpfTest:MainWindowViewModel, IsDesignTimeCreatable=True}"
prism:ViewModelLocator.AutoWireViewModel="True" WindowStartupLocation="CenterScreen">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="/WPFTest;Component/Resources/Resources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<ListView
ItemsSource="{Binding Entries}"
SelectedValue="{Binding SelectedEntry}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.CanContentScroll="True"
SelectionMode="Single"
Margin="10">
<ListView.View>
<GridView>
<GridViewColumn Width="Auto">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox
IsChecked="{Binding Selected}"
Command="{Binding DataContext.RowSelectedCommand, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
HorizontalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
<GridViewColumnHeader>
<ComboBox
ItemsSource="{Binding Options.Items}"
SelectedValue="{Binding Options.SelectedItem}"
ItemTemplateSelector="{DynamicResource itemTemplateSelector}"
HorizontalAlignment="Stretch"
Margin="0,0,0,0"
VerticalAlignment="Stretch"
Width="44"
Height="34"
FontSize="20"
VerticalContentAlignment="Top"
HorizontalContentAlignment="Left">
<ComboBox.Resources>
<DataTemplate x:Key="selectedTemplate">
<TextBlock
x:Name="displayText"
Text="{Binding DataContext.Options.SelectedDisplay, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
FontSize="20"
Height="22"/>
</DataTemplate>
<DataTemplate x:Key="dropDownTemplate">
<TextBlock Text="{Binding}" FontSize="12"/>
</DataTemplate>
<local:ComboBoxItemTemplateSelector
x:Key="itemTemplateSelector"
SelectedTemplate="{StaticResource selectedTemplate}"
DropDownTemplate="{StaticResource dropDownTemplate}"/>
</ComboBox.Resources>
</ComboBox>
</GridViewColumnHeader>
</GridViewColumn>
<GridViewColumn
Width="Auto"
DisplayMemberBinding="{Binding Type, Mode=OneWay}"
Header="Type"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Mvvm;
using WPFTest.Models;
namespace WPFTest.ViewModels
{
/// <summary>
/// View model for the main window view.
/// </summary>
public class MainWindowViewModel : BindableBase
{
private Entry selectedEntry;
private List<Entry> entries;
private SelectOption options;
private DelegateCommand rowSelectedCommand;
/// <summary>
/// Constructor for the view model.
/// </summary>
public MainWindowViewModel()
{
this.Entries = new List<Entry>()
{
new Entry()
{
Description = "My description.",
EffectiveDate = DateTime.Now,
ID = 1,
LastChangeTime = DateTime.Now,
LastChangeUser = "Me",
Selected = false,
Type = "Mine"
},
new Entry()
{
Description = "Your description.",
EffectiveDate = new DateTime(2015, 8, 5, 8, 35, 22, 0),
ID = 12345,
LastChangeTime = new DateTime(2015, 8, 5, 8, 35, 22, 0),
LastChangeUser = "You",
Selected = false,
Type = "Yours"
}
};
this.Options = new SelectOption();
this.Options.SelectChanged = () => { this.OptionsChanged(); };
this.Options.Items = new List<string>() { string.Empty, "All", "None", "Mine", "Yours" };
this.Options.SelectedItem = "None";
}
public Entry SelectedEntry
{
get { return this.selectedEntry; }
set { SetProperty(ref this.selectedEntry, value); }
}
public List<Entry> Entries
{
get { return this.entries; }
set { SetProperty(ref this.entries, value); }
}
public SelectOption Options
{
get { return this.options; }
set { SetProperty(ref this.options, value); }
}
public ICommand RowSelectedCommand
{
get
{
if (this.rowSelectedCommand == null)
{
Func<bool> canExecute = () =>
{
return true;
};
Action execute = () =>
{
this.Options.SelectedItem = string.Empty;
};
this.rowSelectedCommand = new DelegateCommand(execute, canExecute);
}
return this.rowSelectedCommand;
}
}
private void OptionsChanged()
{
if (this.Options.SelectedItem != string.Empty)
{
foreach (Entry entry in this.Entries)
{
switch (this.Options.SelectedItem)
{
case "All":
entry.Selected = true;
break;
case "None":
entry.Selected = false;
break;
case "Mine":
case "Yours":
entry.Selected = entry.Type == this.Options.SelectedItem;
break;
}
}
}
bool selected = this.Entries.Any(e => e.Selected);
bool deselected = this.Entries.Any(e => !e.Selected);
this.Options.UpdateDisplay(selected, deselected);
}
}
}
Microsoft.CSharp
Microsoft.Practices.Prism.Mvvm // Package
Microsoft.Practices.Prism.Mvvm.Desktop
Microsoft.Practices.Prism.SharedInterfaces
PresentationCore
PresentationFramework
PresentationFramework.Royale
System
System.Core
System.Data
System.Data.DataSetExtensions
System.Xaml
System.Xml
System.Xml.Linq
WindowBase
<!-- Resources/Resources.xaml -->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Royale="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Royale">
<ControlTemplate x:Key="ComboBoxControlTemplate1" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
</Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup" AllowsTransparency="True" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
<Royale:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
<Border x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<ScrollViewer x:Name="DropDownScrollViewer">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
<Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
</Canvas>
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
</ScrollViewer>
</Border>
</Royale:SystemDropShadowChrome>
</Popup>
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot" BorderBrush="#FFACACAC" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True">
<Border.Background>
<!--<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF0F0F0" Offset="0"/>
<GradientStop Color="#FFE5E5E5" Offset="1"/>
</LinearGradientBrush>-->
<SolidColorBrush Color="Yellow"/>
</Border.Background>
<Border x:Name="splitBorder" BorderBrush="Transparent" BorderThickness="1" HorizontalAlignment="Right" Margin="0" SnapsToDevicePixels="True" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="Arrow" Data="F1M0,0L2.667,2.66665 5.3334,0 5.3334,-1.78168 2.6667,0.88501 0,-1.78168 0,0z" Fill="#FF606060" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center"/>
</Border>
</Border>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="true"/>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="White"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FFABADB3"/>
<Setter Property="Background" TargetName="splitBorder" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="Transparent"/>
</MultiDataTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" TargetName="Arrow" Value="Black"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="false"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFECF4FC" Offset="0"/>
<GradientStop Color="#FFDCECFC" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FF7EB4EA"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="White"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FF7EB4EA"/>
<Setter Property="Background" TargetName="splitBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFEBF4FC" Offset="0"/>
<GradientStop Color="#FFDCECFC" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="#FF7EB4EA"/>
</MultiDataTrigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Fill" TargetName="Arrow" Value="Black"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="false"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFDAECFC" Offset="0"/>
<GradientStop Color="#FFC4E0FC" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FF569DE5"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="White"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FF569DE5"/>
<Setter Property="Background" TargetName="splitBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFDAEBFC" Offset="0"/>
<GradientStop Color="#FFC4E0FC" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="#FF569DE5"/>
</MultiDataTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Fill" TargetName="Arrow" Value="#FFBFBFBF"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="false"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="#FFF0F0F0"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FFD9D9D9"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="White"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FFBFBFBF"/>
<Setter Property="Background" TargetName="splitBorder" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="Transparent"/>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
<Setter Property="Color" TargetName="shadow" Value="#71000000"/>
</Trigger>
<Trigger Property="HasItems" Value="False">
<Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="True"/>
<!--<Condition>
<Condition.Value>
<sys:Boolean>False</sys:Boolean>
</Condition.Value>
</Condition>-->
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
</MultiTrigger>
<Trigger Property="CanContentScroll" SourceName="DropDownScrollViewer" Value="False">
<Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
<Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style
TargetType="{x:Type ComboBox}">
<!-- Uncomment the following Setter to change the ComboBox background. -->
<!--<Setter Property="Template"
Value="{StaticResource ComboBoxControlTemplate1}" />-->
</Style>
</ResourceDictionary>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace WPFTest.Models
{
/// <summary>
/// Class for the CheckBoxColumnHeader ComboBox options.
/// </summary>
public class SelectOption : INotifyPropertyChanged
{
/// <summary>
/// The display value options.
/// </summary>
private List<SelectOptionDisplay> displays;
/// <summary>
/// The selected display value option.
/// </summary>
private string selectedDisplay;
/// <summary>
/// The drop-down items.
/// </summary>
private List<string> items;
/// <summary>
/// The selected drop-down item.
/// </summary>
private string selectedItem;
/// <summary>
/// The SelectOption constructor.
/// </summary>
public SelectOption()
{
this.displays = new List<SelectOptionDisplay>()
{
new SelectOptionDisplay() { Symbol = "\u2611", Value = "All" },
new SelectOptionDisplay() { Symbol = "\u2610", Value = "None" },
new SelectOptionDisplay() { Symbol = "\u2612", Value = "Some" },
};
}
/// <summary>
/// The property changed event handler.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// The drop-down items.
/// </summary>
public List<string> Items
{
get
{
return this.items;
}
set
{
this.items = value;
this.OnPropertyChanged("Items");
}
}
/// <summary>
/// The selected drop-down item.
/// </summary>
public string SelectedItem
{
get
{
return this.selectedItem;
}
set
{
this.selectedItem = value;
this.OnPropertyChanged("SelectedItem");
this.SelectChanged.Invoke();
}
}
/// <summary>
/// The selected display option symbol.
/// </summary>
public string SelectedDisplay
{
get
{
return this.selectedDisplay;
}
set
{
this.selectedDisplay = value;
this.OnPropertyChanged("SelectedDisplay");
}
}
/// <summary>
/// Action to take on SelectedItem changed event.
/// </summary>
public Action SelectChanged { get; set; }
/// <summary>
/// Update the anySelected display based on the columns selections.
/// </summary>
/// <param name="anySelected">True if any CheckBoxes in the column are checked.</param>
/// <param name="anyDeselected">True if any CheckBoxes in the column are not checked.</param>
public void UpdateDisplay(bool anySelected, bool anyDeselected)
{
if (anySelected && !anyDeselected)
{
this.SelectedDisplay = this.displays.Single(opt => opt.Value == "All").Symbol;
}
else if (anySelected && anyDeselected)
{
this.SelectedDisplay = this.displays.Single(opt => opt.Value == "Some").Symbol;
}
else if (!anySelected && anyDeselected)
{
this.SelectedDisplay = this.displays.Single(opt => opt.Value == "None").Symbol;
}
}
/// <summary>
/// Raise the PropertyChanged event.
/// </summary>
/// <param name="propertyName">The name of the changed property.</param>
protected void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
/// <summary>
/// The display object.
/// </summary>
internal class SelectOptionDisplay
{
/// <summary>
/// The display unicode symbol string.
/// </summary>
public string Symbol { get; set; }
/// <summary>
/// The display value string.
/// </summary>
public string Value { get; set; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment