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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:44:00+00:00 2026-06-06T08:44:00+00:00

I have a strange problem where a XAML control is not visible in the

  • 0

I have a strange problem where a XAML control is not visible in the code behind. Here is a sample of the XAML:

<ListView Name="lvtest" Grid.Row="2" Grid.ColumnSpan="2" Margin="0,20,0,0" 
              ItemsSource="{Binding Content}" >
    <ListView.ItemTemplate>
        <DataTemplate>     
            <StackPanel>                                
                <WebView Name="contentView" Style="{StaticResource BodyTextStyle}" />
                <TextBlock Name="testtxt" Text="{Binding}" Style="{StaticResource BodyTextStyle}" Foreground="GreenYellow"/>

In the code behind:

this.lvtest is recognised, but:

this.contentView and this.testtxt are both not.

I’ve also tried x:Name.

I’m clearly missing something obvious here, I just can’t see what.

EDIT:

To clarify, the textbox control was going to be used to display some formatted text based on the binding, but what I have discovered is that the text is HTML formatted (this suggests using a WebView control). As far as I can see I need to NavigateToString to use the WebView control, and so can’t bind it as such.

  • 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-06-06T08:44:05+00:00Added an answer on June 6, 2026 at 8:44 am

    What you’re missing is that the elements defined in a DataTemplate may be on the page any number of times, which can even change while running. Which one should be linked to the contentView field? There’s no good way to answer that, so it simply doesn’t create a contentView field.

    To put it another way, you’re not defining that the page includes those elements, you’re declaring a template from which .NET can create elements.

    If you let us know how you’re trying to use it, we might be able to suggest another way.

    Edit: Something like this might work for you:

    <WebView Loaded="contentView_Loaded" Style="{StaticResource BodyTextStyle}" />
    

    Then in the code:

    void contentView_Loaded(object sender, EventArgs e)
    {
        var contentView = (WebView)sender;
        var dataContext = (YourDataType)contentView.DataContext;
        // do something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem with virtualization enabled ListView control. I created a very
I have the following XAML code as part of a custom control: <telerik:RadTreeView x:Name=treeModules>
I have a strange WPF/XAML problem. By default, I want all of the nodes
I have a strange problem that I could not solve. When I try to
We are facing a strange problem. We have a user control written in WPF
I have a strange problem when using Entity Framework code first. When I return
I have a strange problem here, I want to create an emtpy trigger: SET
I have strange problem... My file strings.xml contains: <?xml version=1.0 encoding=utf-8?> <resources> <string name=building_name>My
I am having a kinda strange problem. Here is the situation. I have a
Yet another strange WPF error: I have a custom control in a simple XAML

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.