An Original Idea

because all great software begins with an original idea

Creating Commands in XAML only

Posted by anoriginalidea on June 6, 2007

Previously I posted an article about defining “Commands” in WPF applications and responding in code.

A way of doing this in XAML only is setting up a binding to a property on another control.

In this example, a toggle button is used to toggle the blod state on a rich text box.

For example:

<Toolbar>

<ToggleButton MinWidth="40" Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=XAMLRichBox}" TextBlock.FontWeight="Bold">B</ToggleButton>

</Toolbar>

 

I got this idea from this article: Mastering the WPF RichTextBox

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>