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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:54:59+00:00 2026-06-17T09:54:59+00:00

In following the MVVM architecture for WPF, learning WPF DataBindings. I have a single

  • 0

In following the MVVM architecture for WPF, learning WPF DataBindings. I have a single instance of an object instantiated at runtime with the XAML code <p:MemoryPersistentStorageBridge x:Key="persistentMemoryBridge" /> within Window Resources. I am trying to obtain data from the object instance, and plop it into a TextBox as an example, but I am not getting any text in that text box.

XAML:

<Window x:Class="UserConsole.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:PollPublicDataStock;assembly=PollPublicDataStock"
        xmlns:local="clr-namespace:UserConsole"
        Title="MainWindow" Height="900" Width="800">

    <Window.Resources>
        <p:MemoryPersistentStorageBridge x:Key="persistentMemoryBridge" />
    </Window.Resources>


    <Grid Name="grid1" >
         <!--  layout defintions  -->
        <TextBox DataContext="{StaticResource persistentMemoryBridge}"   Text="{Binding Path=GetConnectionString}" Margin="0,327,31,491" Foreground="Black" Background="Yellow"/>
    </Grid>
</Window>

CodeBehind:

public class MemoryPersistentStorageBridge {

    public MemoryPersistentStorageBridge() {

    }

   public string GetConnectionString() {
        return "THISTEXTSHOULDAPPEARINTEXTBOXBUTSADLYDOESNOT";
    }

}
  • 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-17T09:55:00+00:00Added an answer on June 17, 2026 at 9:55 am

    You are trying to bind to a method. You need to bind to a property. Or else use an ObjectDataProvider.

    So you could do this:

    public class MemoryPersistentStorageBridge {
    
         public MemoryPersistentStorageBridge() {
    
        }
    
        public string ConnectionString {
            get { return GetConnectionString(); }
        }
    
       public string GetConnectionString() {
            return "THISTEXTSHOULDAPPEARINTEXTBOXBUTSADLYDOESNOT";
        }
    
    }
    

    or even:

    public class MemoryPersistentStorageBridge {
    
         public MemoryPersistentStorageBridge() {
    
        }
    
        public string ConnectionString {
            get { return "THISTEXTSHOULDAPPEARINTEXTBOXBUTSADLYDOESNOT"; }
        }
    
    }
    

    Of course, in either case we are not handling changing the property and notifying the binding of a change.

    The other option is to use the ObjectDataProvider to wrap your method. This is illustrated in the link I provided. But would look something like this:

    <ObjectDataProvider ObjectInstance="{StaticResource persistentMemoryBridge}"
                      MethodName="GetConnectionString" x:Key="connectionString">
    </ObjectDataProvider>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying my hands on WPF MVVM. I have written following code in
Form Build your own MVVM I have the following code that lets us have
I am working through an MVVM tutorial, and I have the following code, written
In a WPF application following MVVM pattern I have a Customer class which has
I use C#, MVVM, WPF and Resharper. When using the following code: public bool
I'm relatively new to using WPF and the MVVM architecture. I have a question
I'm using MVVM in WPF in C#.NET. Say I have the following example model:
I have just started learning MVVM. I've made the application from scratch by following
I have the following style in my WPF MVVM app. <Style x:Key=DefaultCalendar TargetType=Calendar> <Setter
I am following wpf/mvvm method. I need to have a tab control...with multiple rows..i

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.