This question is locked. New answers and comments are not allowed.
Hi,
I have a problem with setting binding beetween a textbox and a gridView's field in Q2.
I ve read about the example but in my project i ve realized the binding not directly in the xaml but in the code behind.
It seems to work.
At the beginning the first binding works, so my textbox is populated with the correct data but after the first binding when i change the current item the binding doensn't follow my chooice and doesn't work.
Here you are my code.
thanks for help.
Enrico Valiani - Italy
I have a problem with setting binding beetween a textbox and a gridView's field in Q2.
I ve read about the example but in my project i ve realized the binding not directly in the xaml but in the code behind.
It seems to work.
At the beginning the first binding works, so my textbox is populated with the correct data but after the first binding when i change the current item the binding doensn't follow my chooice and doesn't work.
Here you are my code.
| public static Grid CreaGrigliaDettaglio(Telerik.Windows.Controls.RadGridView griglia, int[] larghezzaColonne) |
| { |
| Grid nuovaGriglia = new Grid(); |
| //definizione griglia |
| //colonne |
| for (int i = 0; i < larghezzaColonne.Length; i++) |
| { |
| ColumnDefinition c = new ColumnDefinition(); |
| c.Width = new GridLength(larghezzaColonne[i], GridUnitType.Star); |
| nuovaGriglia.ColumnDefinitions.Add(c); |
| } |
| //righe |
| List<Helper.Configurazioni.Colonna> lista = Helper.Configurazioni.ritornaGriglia(griglia.Name); |
| for (int i = 0; i < (lista.Count / larghezzaColonne.Length); i++) |
| { |
| RowDefinition r = new RowDefinition(); |
| nuovaGriglia.RowDefinitions.Add(r); |
| } |
| TextBlock tbk; |
| TextBox tbx; |
| Binding selectBinding; |
| for (int i = 0; i < lista.Count; i++) |
| { |
| sp = new StackPanel(); |
| sp.Orientation = Orientation.Horizontal; |
| tbk = new TextBlock(); |
| //tbk.Text = LocalizationManager.GetString(lista[i].ColonnaUniquename); |
| tbk.Text = lista[i].ColonnaUniquename; |
| sp.Children.Add(tbk); |
| tbx = new TextBox(); |
| selectBinding = new Binding(); |
| selectBinding.Mode = BindingMode.TwoWay; |
| selectBinding.Path = new System.Windows.PropertyPath(lista[i].ColonnaUniquename); |
| selectBinding.Source = griglia.CurrentItem; |
| tbx.SetBinding(TextBox.TextProperty, selectBinding); |
| sp.Children.Add(tbx); |
| sp.SetValue(Grid.RowProperty, (i / larghezzaColonne.Length)); |
| sp.SetValue(Grid.ColumnProperty, (i % larghezzaColonne.Length)); |
| nuovaGriglia.Children.Add(sp); |
| } |
| nuovaGriglia.ShowGridLines = false; |
| return nuovaGriglia; |
| } |
| } |
thanks for help.
Enrico Valiani - Italy