Creating Commands in XAML only


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:


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



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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s