-
Notifications
You must be signed in to change notification settings - Fork 263
WPF Markup Extensions in ATF
Markup extensions allow you to return an object as an attribute value in XAML. A markup extension derives from the System.Windows.Markup.MarkupExtension
class. The constructors for the class can take whatever parameters are needed. The ProvideValue()
method returns the object for the attribute value, so the markup extension class has complete flexibility in computing the value.
LocExtension
provides an example of how an extension can provide localization services. Its main constructor takes a string to be localized:
public LocExtension(string key)
Its ProvideValue()
method is very simple:
public override object ProvideValue(IServiceProvider serviceProvider)
{
if (string.IsNullOrEmpty(Key))
return string.Empty;
return string.IsNullOrEmpty(Format) ? Key.Localize() : string.Format(Format, Key.Localize());
}
Using LocExtension
allows you to localize text in the XAML file, and numerous XAML files in ATF use this markup extension. For instance, here are some lines from OutputView.xaml
for dialogs that display text output to a user:
<MenuItem Header="{m:Loc Copy to Clipboard}" Command="ApplicationCommands.Copy"/>
<MenuItem Header="{m:Loc Clear All}" Command="{StaticResource ClearAllRef}"/>
ATF provides a variety of markup extensions in the Sce.Atf.Wpf.Markup
namespace. Here are several with a description of what the ProvideValue()
method provides.
-
CommandServiceExtension
:ICommandItem
representing a command. -
ConverterMarkupExtension<T>
: Newly constructed converter object for a given type. ATF has many WPF converters that derive from this class. -
EnumValuesExtension
: Array of enumeration members representing the enum values of the given enumeration type. -
GenericExtension
: Concrete object of a given generic type. -
LocExtension
: Localized version of a given string. -
MultiConverterMarkupExtension<T>
: Newly constructed multiconverter object for a given type for multibinding. ATF has several WPF multiconverters that derive from this class. -
ResourceKeyBinding
: Data binding for a given resource key. -
TypeConverterExtension
: Type converter from one type to another, specifying source and target types.
- ATF and WPF Overview: Overview of what ATF offers for WPF.
- WPF Application: Discuss how WPF applications differ from WinForms ones in basic application structure.
- Parallels in WPF and WinForms Support: Discusses features WPF offers that are similar to WinForms.
- WPF Application Support: Discussion of classes generally supporting applications.
- WPF Dialogs in ATF: WPF dialogs you can use.
- WPF Behaviors in ATF: ATF support for WPF behaviors.
- WPF Markup Extensions in ATF: ATF support for WPF Markup extensions.
- WPF ViewModels in ATF: Discuss WPF ViewModel support in ATF.
- Converting from WinForms to WPF: Tells how to convert a WinForms ATF-based application to WPF.
- Home
- Getting Started
- Features & Benefits
- Requirements & Dependencies
- Gallery
- Technology & Samples
- Adoption
- News
- Release Notes
- ATF Community
- Searching Documentation
- Using Documentation
- Videos
- Tutorials
- How To
- Programmer's Guide
- Reference
- Code Samples
- Documentation Files
© 2014-2015, Sony Computer Entertainment America LLC