error handling?

When a XAML element has an attribute that it doesn't support, nothing renders and there's no alert.

I also tried specifying my own error handler, instead of the null argument in the new agHost(...) call. That wasn't called either.

I hope this isn't the intended behavior, because it sure makes debugging difficult. If that's not the normal behavior, could someone suggest how I can get it to work, or at least allow it to render the whole XAML document ignoring the offending element

Actually, I would expect that both the error handler would be called and everything else would be rendered and the offending attribute would be ignored. Perhaps the non-rendering behavior is due to over-zealous validation, but I don't think that is a wise policy.

I'm running on Vista, IE7, Feb CTP.



Answer this question

error handling?

  • alexmy5

    Although such a conservative approach towards versioning is plausible, I really believe that a liberal approach towards supporting forwards compatibility should be strongly preferred for this kind of open system.

    I'm not saying there shouldn't be new namespaces for distinct and major new features. It's just that many kinds of additions, such as adding support for a TextAlignment attribute on the TextBlock element, can easily be handled in a forwards-compatible manner. So having a strict validation policy will unnecessarily inconvenience both consumers and producers of WPF/E.


  • ManjuVijay

    As future versions of WPF/E are released there will probably be a new namespace for the new features. Plus since you control what version of the WPF/E control is being used, you can decide which version of the xaml to use.

    BTW - this is only my $.02, not the MS answer. :)


  • - Slash

    Well, if being so strict is the policy, how should programmers/designers expect to handle compatibility problems when future versions of WPF/e support additional elements/attributes Or will everyone have to produce "1.0" least-common-denominator XAML forever
  • Aaron Oneal

    I think nothing is loaded because it doesn't pass the schema validation. You can get the information you're looking for since it does work in samples like WPFEPad. Here is the javascript used in that sample:

    function handleParseError(line, col, hr, string)
    {
    var str = string + " at: " + line + ", " + col;

    var wpfeControl = document.getElementById("wpfeControl1");
    var errorTextBlock = wpfeControl.findName("errorTextBlock");
    errorTextBlock.foreground = "red";
    errorTextBlock.text = str;
    }

    And the aghost call looks like this:

    new agHost("WpfeControlHost2", "wpfeParseTest", "1", "1", "#00000000", null, "xaml/Scene.xaml", "-1", "5", "handleParseError");

    Give that a try and see if it works for you. If you try out that sample and input some invalid xaml you will see the parser error...


  • error handling?