Skip to content

Instantly share code, notes, and snippets.

@BryanWilhite
Created November 13, 2014 00:30
Show Gist options
  • Save BryanWilhite/1689b6906512822a5a0d to your computer and use it in GitHub Desktop.
Save BryanWilhite/1689b6906512822a5a0d to your computer and use it in GitHub Desktop.
C#, Silverlight/Telerik: RadMultiSelectDropDownColumn
using System.Windows;
using GalaSoft.MvvmLight.Messaging;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
namespace Fox.Xavier.Client.Views
{
using Fox.Silverlight.Controls;
using Fox.Silverlight.Models;
/// <summary>
/// Custom column wrapping a custom control.
/// </summary>
/// <remarks>
/// <c>GridViewBoundColumnBase</c> provides overrides
/// that fire consistently in the GridView.
///
/// Wrapping a custom control in, say, the <c>DataTemplate</c>
/// of an unbound/bound column will not provide the same consistency.
/// </remarks>
public class RadMultiSelectDropDownColumn : GridViewBoundColumnBase
{
public override bool CanEdit(object item)
{
return false;
}
public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
{
var dropdown = new MultiSelectDropDown
{
DisplayMemberPath = "DisplayText",
DropDownSummaryFormat = "{0} dpts selected",
SelectedValuePath = "Id"
};
var content = new LightContentForFrameworkElement<MultiSelectDropDown>
{
Element = dropdown,
DataOfContext = dataItem
};
var message = new LightMessage<LightContentForFrameworkElement<MultiSelectDropDown>>(content)
{
Source = LightMessageSource.ViewAddedChildren,
UniqueId = this.UniqueName
};
Messenger.Default.Send(message);
return dropdown;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment