|
using System.Windows;
using System.Windows.Controls;
namespace GG.GameAttackCombos.Client {
/// <summary>
/// A DataTemplateSelector for the combo box used to display the available button sets.
/// </summary>
/// <remarks>
/// This template selector will use a standard template that displays the button set's
/// Name property, unless a ContentPresenter is present inside a ComboBox; this indicates
/// that the text in the selection box area is being displayed. We want to show both the
/// platform and the name of the button set in this case.
/// </remarks>
public class ButtonSetsTemplateSelector : DataTemplateSelector {
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
string ResourceKey = "ButtonSetByName";
// Get the main window.
Window Window = Application.Current.MainWindow;
// Test if the container is a ContentPresenter.
ContentPresenter Presenter = container as ContentPresenter;
if (Presenter != null) {
ComboBox Combo = Presenter.TemplatedParent as ComboBox;
if (Combo != null) {
ResourceKey = "ButtonSetByPlatformAndName";
}
}
return Window.FindResource(ResourceKey) as DataTemplate;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I began programming on my Commodore 64 at around the age of 12. After migrating to DOS and then Windows, I decided to take on the Web. Several languages and platforms later, I have settled in with .NET nicely. I am currently the owner of a software consulting company and lead application developer for a learning-based technology consultation company.
The love of a finished application is usually at war with the desire to improve it as soon as it's released (they're never really finished).