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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:50:57+00:00 2026-05-29T10:50:57+00:00

This is a really strange issue, this is the last page that i was

  • 0

This is a really strange issue, this is the last page that i was working on, i used to make an ObservableCollection of the ListBox to add the data in the textblocks and image and bind the data.

But this time i only have 1 TextBlock and 1 Image that i need to bind the Data to it.
In the .cs file, i can’t access them directly and also DataBinding is not working.

Xaml:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <TextBlock Text="{Binding lastName}" Height="33" Margin="0,175,8,0" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Right" Width="336" />
        <ListBox ItemsSource="{Binding lastAddress}" Margin="8,291,8,8"/>
        <TextBlock HorizontalAlignment="Left" Height="33" Margin="8,0,0,0" TextWrapping="Wrap" Text="Restaurant Profile: " VerticalAlignment="Top" Width="225" TextDecorations="Underline" Foreground="#FF7A0100" FontSize="24"/>
        <Image Source="{Binding lastImage}" Height="132" Margin="8,37,292,0" VerticalAlignment="Top" Stretch="None"/>
    </Grid>

Any help ?
Thanks.

  • 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-29T10:50:58+00:00Added an answer on May 29, 2026 at 10:50 am

    Looks like you have a couple of potential problems here. First of all, if you want to access your controls from your codebehind .cs file, you need to give the controls names, like this:

    <Grid Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <TextBlock Name="MyTextBlock" />
    </Grid>
    

    Then they are accessible in your codebehind:

    public MainPage()
    {
        InitializeComponent();
        DoStuff();
    }
    
    private void DoStuff() 
    {
        MyTextBlock.Text = "Hey, it works!";
    }
    

    Second, in order to get the databinding working, you need to set the DataContext for your page, either in the XAML or in your codebehind file.

    In the codebehind file, you can do it like this:

    public MainPage()
    {
        InitializeComponent();
        LayoutRoot.DataContext = this;
    }
    

    Which allows you to databind like this:

    <Grid Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <TextBlock Name="MyTextBlock" Text="{Binding MyProperty}"/>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a really strange issue. One day my project started to do a
This is really strange but this code is working fine unless the value entered
This is a really strange problem, that appears to be somewhat intermittent (although it
This is a really strange issue. When using WebClient.DownloadFile in Debug configuration, it appears
This is a really strange issue, I am trying to use the Recaptcha on
Since upgrading to Xcode 3.2.1, I've experienced a strange issue that has really killed
I am having a really strange issue with my edit page: If I have
This is a pretty strange issue, but I think it might be that I
This is a really strange issue. I have developed a small MVC application and
This is a really strange issue, and I can't for the life of me

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.