Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [Solved] Binding to data that will be resloved asyncronously

[Solved] Binding to data that will be resloved asyncronously

Scheduled Pinned Locked Moved C#
wpfwcfhelptutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlphaDeltaTheta
    wrote on last edited by
    #1

    Hi all, Just got a view and a viewmodel to wire-up. The view needs to be bound to some properties that will be resolved asyncly after the execution of a certain command. Ok, I wrote all the stuff but now i'm confused with how to declare the binding??? Any ideas???? Here's just a skeleton View - initially just a textbox and a ok button. On clicking the ok button, the results are displayed and the command to resolve values are sent to the viewmodel. In viewmodel,

    public class MainViewModel : ViewModelBase
    {

    //properties that are to be resolved
    
    private string \_data;
    private int \_time;
    
    public string Data
    {
    	get
    	{
    		return \_data;
    	}
    		set
    	{
    		\_data = value;
    		NotifyPropertyChange("Data");
    	}
    }
    
    //and so on...
    

    }

    I need the value of a Textblock to be bound with "Data". But that will be resolved after a while... Out of ideas!:confused: Please help.

    A A B 3 Replies Last reply
    0
    • A AlphaDeltaTheta

      Hi all, Just got a view and a viewmodel to wire-up. The view needs to be bound to some properties that will be resolved asyncly after the execution of a certain command. Ok, I wrote all the stuff but now i'm confused with how to declare the binding??? Any ideas???? Here's just a skeleton View - initially just a textbox and a ok button. On clicking the ok button, the results are displayed and the command to resolve values are sent to the viewmodel. In viewmodel,

      public class MainViewModel : ViewModelBase
      {

      //properties that are to be resolved
      
      private string \_data;
      private int \_time;
      
      public string Data
      {
      	get
      	{
      		return \_data;
      	}
      		set
      	{
      		\_data = value;
      		NotifyPropertyChange("Data");
      	}
      }
      
      //and so on...
      

      }

      I need the value of a Textblock to be bound with "Data". But that will be resolved after a while... Out of ideas!:confused: Please help.

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Try from within the view.

      Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

      A 1 Reply Last reply
      0
      • A Abhinav S

        Try from within the view.

        Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

        A Offline
        A Offline
        AlphaDeltaTheta
        wrote on last edited by
        #3

        This will be enough? :doh: so simple! Ofcourse, the confusion was that it was to be resolved asyncly.

        1 Reply Last reply
        0
        • A AlphaDeltaTheta

          Hi all, Just got a view and a viewmodel to wire-up. The view needs to be bound to some properties that will be resolved asyncly after the execution of a certain command. Ok, I wrote all the stuff but now i'm confused with how to declare the binding??? Any ideas???? Here's just a skeleton View - initially just a textbox and a ok button. On clicking the ok button, the results are displayed and the command to resolve values are sent to the viewmodel. In viewmodel,

          public class MainViewModel : ViewModelBase
          {

          //properties that are to be resolved
          
          private string \_data;
          private int \_time;
          
          public string Data
          {
          	get
          	{
          		return \_data;
          	}
          		set
          	{
          		\_data = value;
          		NotifyPropertyChange("Data");
          	}
          }
          
          //and so on...
          

          }

          I need the value of a Textblock to be bound with "Data". But that will be resolved after a while... Out of ideas!:confused: Please help.

          A Offline
          A Offline
          Anna King
          wrote on last edited by
          #4

          I am still not getting it, how exactly do you want to bind your data with the ViewModel.

          1 Reply Last reply
          0
          • A AlphaDeltaTheta

            Hi all, Just got a view and a viewmodel to wire-up. The view needs to be bound to some properties that will be resolved asyncly after the execution of a certain command. Ok, I wrote all the stuff but now i'm confused with how to declare the binding??? Any ideas???? Here's just a skeleton View - initially just a textbox and a ok button. On clicking the ok button, the results are displayed and the command to resolve values are sent to the viewmodel. In viewmodel,

            public class MainViewModel : ViewModelBase
            {

            //properties that are to be resolved
            
            private string \_data;
            private int \_time;
            
            public string Data
            {
            	get
            	{
            		return \_data;
            	}
            		set
            	{
            		\_data = value;
            		NotifyPropertyChange("Data");
            	}
            }
            
            //and so on...
            

            }

            I need the value of a Textblock to be bound with "Data". But that will be resolved after a while... Out of ideas!:confused: Please help.

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #5

            Binding to that property in the normal way should work fine. Data binding is essentially asynchronous all the time, in that the view's updated by notification events and not directly by code, so it should work just the same. Make sure that the VM sends a value that the view can deal with before the asynchronous call returns, though (this might mean making the view accept null).

            A 1 Reply Last reply
            0
            • B BobJanova

              Binding to that property in the normal way should work fine. Data binding is essentially asynchronous all the time, in that the view's updated by notification events and not directly by code, so it should work just the same. Make sure that the VM sends a value that the view can deal with before the asynchronous call returns, though (this might mean making the view accept null).

              A Offline
              A Offline
              AlphaDeltaTheta
              wrote on last edited by
              #6

              Thank you, Here's my solution,

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups