Created
November 13, 2014 00:30
-
-
Save BryanWilhite/1689b6906512822a5a0d to your computer and use it in GitHub Desktop.
C#, Silverlight/Telerik: RadMultiSelectDropDownColumn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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