This is a migrated thread and some comments may be shown as answers.

[Solved] gridView AND setBinding

1 Answer 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Enrico Valiani
Top achievements
Rank 1
Enrico Valiani asked on 30 Nov 2009, 05:37 PM
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.
            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

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 03 Dec 2009, 11:04 AM
Hello Enrico Valiani,

Can you please upgrade to the latest version. This is our Latest Internal Build from November 27th. Drop us a line if the same problem occurs after you have upgraded to our Latest Internal Build.

Kind regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Enrico Valiani
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or