| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Windows Presentation Foundation (WPF) & XAML forum Ask questions related specifically to WPF. Also ask questions related to XAML. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|