CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > Windows Presentation Foundation (WPF) & XAML forum
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Windows Presentation Foundation (WPF) & XAML forum Ask questions related specifically to WPF. Also ask questions related to XAML.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 4th, 2009, 12:19 PM
    hwafel hwafel is offline
    Junior Member
     
    Join Date: Nov 2009
    Posts: 1
    hwafel is an unknown quantity at this point (<10)
    Databinding problem

    Hi

    I have a problem when binding data from datatable to a TexBox.

    There's a ListBox connected to DataTable and a TextBox connected to one field from the same DataTable.

    This binding in XAML works fine:

    <TextBox Name="txtNazwa" Text="{Binding Path=NAZWA}" />

    moving in a ListBox changes values ina TextBox. But when I'm trying to do binding in code below nothing happens in a TextBox.


    // set "global" datacontext
    grdKartoteka.DataContext = Kartoteka.klejeDataTable.DefaultView;

    // set source for a list (same as datacontext but in case of lists
    // ItemsSource has to be specified
    listNazwyTowarow.ItemsSource = Kartoteka.klejeDataTable.DefaultView;
    listNazwyTowarow.DisplayMemberPath = "NAZWA";

    // binding for a textbox
    Binding binding = new Binding();
    binding.Source = Kartoteka.klejeDataTable.DefaultView;
    binding.Path = new PropertyPath("NAZWA");
    binding.Mode = BindingMode.TwoWay;
    txtNazwa.SetBinding( TextBlock.TextProperty, binding);

    What's wrong?
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > Windows Presentation Foundation (WPF) & XAML forum


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:02 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009