To display a data table in a ListView, I
<ListView ItemsSource="{Binding Source={StaticResource AdministrationView}}" IsSynchronizedWithCurrentItem="True" Name="lvTable"> <ListView.ItemContainerStyle> ... stuff ... </ListView.ItemContainerStyle> <ListView.View> <GridView> <GridViewColumn Header="Pattern"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Path=Pattern}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Account"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Path=AccountName}" /> .... closing tags .......
with resource
<Window.Resources> <CollectionViewSource x:Key="AdministrationView"/> </Window.Resources>
and code for
var db = new XDataContext(); var data = db.Translations; var viewSource = (CollectionViewSource)FindResource("AdministrationView"); viewSource.Source = data;
=====
Now, if I want to display one of several possible tables, I would like to bind the code, so I have
data = .... var tb = new TextBox(); var binding = new Binding("Pattern"); binding.Source = db.Accounts; tb.SetBinding(TextBlock.TextProperty, binding);
but I can't figure out how to attach a TextBox to one of the GridViewColumn (s).
Any thoughts?
thanks
source share