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 6196529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:39:30+00:00 2026-05-24T03:39:30+00:00

I’ve managed to reduce this to a simple test case. An exception is thrown

  • 0

I’ve managed to reduce this to a simple test case. An exception is thrown during the parsing of this XAML using XamlReader.Parse():

<DockPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <DockPanel.Resources>
        <Style TargetType="TextBox">
            <Style.Triggers>
                <Trigger Property="IsReadOnly" Value="True">
                    <Setter Property="Background" Value="#FFEEEEEE" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </DockPanel.Resources>


    <TextBox IsReadOnly="True" />
</DockPanel>

The exception message is:

Cannot set unknown member ‘System.Windows.Controls.TextBox.IsReadOnly’. Line number ’13’ and line position ’11’.

If I don’t set IsReadOnly on the TextBox, it parses fine. It also parses fine if I remove the style trigger.

Can anyone shed some light on this? I’m rather new to WPF.

UPDATE:
Here’s the unit test I’m using to reproduce this (it’s failing on my PC):

[TestMethod]
public void TestIsReadOnlyOnTextBox()
{
    // Arrange
    var xaml =
@"<DockPanel xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
    <DockPanel.Resources>
        <Style TargetType=""TextBox"">
            <Style.Triggers>
                <Trigger Property=""IsReadOnly"" Value=""True"">
                    <Setter Property=""Background"" Value=""#FFEEEEEE"" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </DockPanel.Resources>


    <TextBox IsReadOnly=""True"" />
</DockPanel>
";

    // Act
    try {
        var root = XamlReader.Parse(xaml);
    }
    catch (XamlParseException ex) {
        Assert.Fail(ex.Message);
    }

    // If we get here, test passes
}

UPDATE 2:
I was originally referencing just PresentationFramework v4.0.30319. Adding references to PresentationCore, System.Xaml, and WindowsBase has no effect.

.NET version of project is 4 (full, not client profile).

UPDATE 3:
Arg, this works fine in ExpressionBlend 3.0.1927.0 and XamlPadX 4. As reported by AresAvatar, it seems to only fail when parsed with XamlReader.Parse() or XamlReader.Load()!

  • 1 1 Answer
  • 0 Views
  • 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-24T03:39:31+00:00Added an answer on May 24, 2026 at 3:39 am

    Short answer, clearly this is a bug. The following can be used as a workaround.

    Update, workaround 2

    Even just executing the following line before XamlReader.Parse(xaml) fixes the problem, still clueless as to why though..

    XamlReader.Parse(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                                xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
                                IsReadOnly=""True""/>");
    var root = XamlReader.Parse(xaml);
    

    Workaround 1
    Using Boolean in mscorlib instead of True in the Trigger seems to fix the problem for good. The following xaml does not throw an exception in XamlReader.Parse

    var xaml =
    @"<DockPanel xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                 xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
                 xmlns:s=""clr-namespace:System;assembly=mscorlib"" >
        <DockPanel.Resources>
            <s:Boolean x:Key=""BooleanTrue"">True</s:Boolean>
            <Style TargetType=""TextBox"">
                <Style.Triggers>
                    <Trigger Property=""IsReadOnly"" Value=""{StaticResource BooleanTrue}"">
                        <Setter Property=""Background"" Value=""#FFEEEEEE"" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </DockPanel.Resources>      
        <TextBox IsReadOnly=""True"" />
    </DockPanel>";
    

    Some research details..

    I did some testing of this weird problem.

    First I included the working DockPanel in Xaml and saved it with

    string xaml = XamlWriter.Save(theDockPanel);
    

    just to see if that piece of xaml was working with XamlReader.Parse, and it did.

    Then I made small changes to the generated xaml (and reverted once the exception came back) until I got as close as possible to the original. The weird part is that once this xaml has been parsed, the original works as well.

    The part that made it working seems to be using <s:Boolean>True</s:Boolean> instead of True.

    var modifiedXaml = @"<DockPanel xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                                    xmlns:s=""clr-namespace:System;assembly=mscorlib"" 
                                    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
                    <DockPanel.Resources>
                        <s:Boolean x:Key=""BooleanTrue"">True</s:Boolean>
                        <Style TargetType=""TextBox"">
                            <Style.Triggers>
                                <Trigger Property=""IsReadOnly"" Value=""{StaticResource BooleanTrue}"">
                                    <Setter Property=""Background"" Value=""#FFEEEEEE"" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </DockPanel.Resources>
                    <TextBox IsReadOnly=""True"" />
                </DockPanel>";
    
    var originalXaml = @"<DockPanel xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                                    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
                    <DockPanel.Resources>
                        <Style TargetType=""TextBox"">
                            <Style.Triggers>
                                <Trigger Property=""IsReadOnly"" Value=""True"">
                                    <Setter Property=""Background"" Value=""#FFEEEEEE"" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </DockPanel.Resources>
                    <TextBox IsReadOnly=""{Binding}""/>
                </DockPanel>";
    try
    {
        // If this line is executed, no `XamlParseException` is thrown
        var root = XamlReader.Parse(modifiedXaml);
        var root2 = XamlReader.Parse(originalXaml);
    }
    catch (XamlParseException ex)
    {
    
    }
    

    I’ll update again if I find something more on this..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

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.