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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:22:31+00:00 2026-05-23T05:22:31+00:00

There’s quite a few questions about loading XAML at runtime here, but as far

  • 0

There’s quite a few questions about loading XAML at runtime here,
but as far I can tell this is not a duplicate.

I’m loading XAML into a control at runtime:

<ContentControl Content="{Binding Layout.View, Converter={StaticResource StringToXamlConverter}}"/>

The converter is rather simple:

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    string xaml;
    if (value != null)
    {
        xaml = value.ToString();
    }
    else
    {
        xaml = Settings.Default.DefaultLayoutView;
    }

    var root = XamlReader.Parse(xaml);
    return root;
}

Now, in the XAML that is being loaded, I need to make use of ValueConverters.
The converters are defined as resources of the Window in to which the XAML is loaded. For example:

<c:BooleanToVisibilityValueConverter x:Key="BooleanToVisibilityConverter"/>

Of course, the XamlReader.Parse() method throws an exception if I try to use this resource as at the time of reading it is not available.

Visibility="{Binding Layout.TextItem1.IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}"

Is there a way to get around this?
Perhaps a way to tell the XamlReader to ignore this?
Or an alternative to ValueConverters that might work in this situation?

Please note, using a DynamicResource does not work either. They cannot be used for ValueConverters.

  • 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-23T05:22:31+00:00Added an answer on May 23, 2026 at 5:22 am

    UPDATED

    OK, You are right, dynamic resources will not work. I have come up with two solutions, and the best part is, I have tested and both will actually work.

    Choice 1: Define the static resource in the application resources app.xaml

    Choice 2: Do not use a static resource for the converter, just create the converter in the xaml. Sorry for not going off the xaml you were using, but you’ll get the idea:

    <Button>
        <Button.Visibility>
            <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}">
                <Binding.Converter>
                    <controls:BooleanToVisibilityConverter />
                </Binding.Converter>
            </Binding>                   
        </Button.Visibility>
    
        <Button.Tag>
            <sys:Boolean>True</sys:Boolean>
        </Button.Tag>
    </Button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's a few previous questions on StackOverflow questioning how one goes about accessing local
There are several questions about using .Net DateTime in Sql statements but none of
There are variations of this question bouncing around SO, but none of them seem
There is probably an easy answer for this, but when I added DateTime.Now.ToString() to
There are many tutorials that talk about deleting index.php from the url. But I
There must be a simple solution to this, but after 4 hours of browsing
There's a lot of reading on self referencing problems, but I can't seem to
There are things like f.call(...) f.apply(...) But then there's this (1, alert)('Zomg what is
There are lots of posts on here about moving a folder out of one
There is a lot of information about composition vs inheritance online, but I haven't

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.