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

  • Home
  • SEARCH
  • 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 8309907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:16:05+00:00 2026-06-08T19:16:05+00:00

MainPage.xaml <TextBlock Text={Binding Pathname, Source={StaticResource ViewModel}, Mode=OneWay} /> App.xaml <ResourceDictionary> <vm:InspectViewModel x:Key=ViewModel /> </ResourceDictionary>

  • 0

MainPage.xaml
<TextBlock Text="{Binding Pathname, Source={StaticResource ViewModel}, Mode=OneWay}" />

App.xaml

<ResourceDictionary>
     <vm:InspectViewModel x:Key="ViewModel" />
</ResourceDictionary>

ViewModel

private string _pathname = null;
public string Pathname
{
    get { return _pathname; }
    set
    {
        if (_pathname != value)
        {
            _pathname = value;
            RaisePropertyChanged("Pathname");
        }
    }
}

public void UpdatePathname(string path)
{
    Pathname = path;
}

MainPage CodeBehind

private void lazyNavTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)  
{          
    InspectViewModel vm = new InspectViewModel();        
    var path = view.GetPath().ToArray();
    string pathname = null;
    // to figure out what the pathname is
    for (int i = 0; i < path.Count(); i++)
    {
        TreeList treeItem = (TreeList)path[i].Key;
        if (i == path.Count()-1)
            pathname = pathname + treeItem.Name;
        else
            pathname = pathname + treeItem.Name + " : ";
    }
    vm.UpdatePathname(pathname);
}

The bound TextBlock shows nothing, nada, zip. The pathname shource is changing correctly but nothing seems to happen when I fire the INotifyPropertyChanged event on change.

I am sure I’m missing something really obvious but I can’t figure out what!

  • 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-08T19:16:06+00:00Added an answer on June 8, 2026 at 7:16 pm

    You are creating 2 instances of your ViewModel:

    • in App.xaml (in app resources, this is the instance which is bound to)
    • in MainPage code-behind (InspectViewModel vm = new InspectViewModel(), this is the modified instance)

    You should use single instance of you ViewModel, for example,

    var vm = (InspectViewModel)Application.Current.Resources["ViewModel"];
    

    instead of creating it in MainPage code-behind.

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

Sidebar

Related Questions

I am writing this in XAML <TextBlock Text={Binding Path=Test} Grid.Column=1 Margin=52,46,32,50 Name=textBlockCheck /> and
in my silverlight for windows phone app, i've created this xaml in the mainpage
I am completely new developer at Windows Phone 7. I have TextBlock Text={Binding MyDate}
I have a style for a textblock that is set inside my app.xaml this
I have a view (MainPage.xaml) which is bound to a ViewModel. In the ViewModel
I have this code in MainPage.xaml: <controls:PivotItem Header=first> <ListBox x:Name=MyListBox Margin=0,0,-12,0 ItemsSource={Binding ListBoxItem}> <ListBox.ItemTemplate>
I have a Page in Silverlight which is Navigated from the MainPage.xaml, called OpenPage.xaml,
I have created blank C#/XAML Windows 8 application. Add simple XAML code: <Page x:Class=Blank.MainPage
In my Mainpage.xaml.cs file I have a function that creates an instance of another
The mainpage: MainPage.xaml <Canvas x:Name=LayoutRoot Background=White> </Canvas> MainPage.xaml.cs List<Usol> list = new List<Usol>(); for

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.