Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 813557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:22:47+00:00 2026-05-15T01:22:47+00:00

For a few months I have been successfully using David Justices Default Button example

  • 0

For a few months I have been successfully using David Justices Default Button example in my SL 3 app. This approach is based on an attached property.

After upgrading to SL4, the approach no longer works, and I get a XAML exception:

Unknown parser error: Scanner 2148474880

Has anyone succesfully used this (or any other) default button attached behaviours in SL4?

Is there any other way to achieve default button behaviour in SL4 with the new classes that are available?

Thanks,
Mark

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:22:48+00:00Added an answer on May 15, 2026 at 1:22 am

    I extended David’s approach by allowing a custom key (defaulted to Enter) to be set in an additional property:

        public static DependencyProperty ButtonKeyProperty = DependencyProperty.RegisterAttached(
             "ButtonKey",
             typeof(Key),
             typeof(Defaults),
             new PropertyMetadata(Key.Enter, ButtonChanged));
    
        public static void SetButtonKey(DependencyObject dependencyObj, Key key)
        {
            dependencyObj.SetValue(ButtonKeyProperty, key);
        }
    
        public static Key GetButtonKey(DependencyObject dependencyObj)
        {
            return (Key)dependencyObj.GetValue(ButtonKeyProperty);
        }
    

    I modified the original property to then leverage this property:

        Key key = GetButtonKey(dependencyObj);
        if (button.IsEnabled && keyEvent.Key == key)
            ...
    

    So now, for example, I can use Escape as the key if I want (note I changed the named of the classes and properties):

        ... UI:Defaults.Button="{Binding ElementName=myButton}" UI:Defaults.ButtonKey="Escape" ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using fullcalendar plugin successfully for a few months and suddenly ran
I have been using ASP.NET MVC for the past few months, after successfully ignoring
EDIT: I have been using Postgres with PostGIS for a few months now, and
I have been using Grails for the past few months and I really like
We have been using Scrum for a few months and I have never felt
I have been using linq in combination with entity framework for a few months
I have been dealing with this for a few months now. My flex apps
I have been using Netbeans for my java desktop application since few months. Now
I have been using jqGrid for a few months now, and I have made
I have been developing an application over the last few months using EF code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.