DataGrid list binding
-
Can anybody see what's going wrong here? I get an empty grid with a blank row for each item in the ObservableCollection .
<Custom:DataGrid Width="454" Height="396" Canvas.Left="8" Canvas.Top="4" Name="gridEvents" FontWeight="Bold" FontFamily="Nina" AutoGenerateColumns="False" SelectedIndex="0" FontSize="10.667" > <Custom:DataGrid.Columns> <Custom:DataGridTextColumn x:Name="dgCol\_EVStatus" Header ="Status" FontWeight="Normal" IsReadOnly="True" /> </Custom:DataGrid.Columns> </Custom:DataGrid>
and
dgCol_EVStatus.Binding = new System.Windows.Data.Binding("Status");
ObservableCollection<RIAudit> _Audits = new ObservableCollection<RIAudit>();
_Audits.Add(auditRec);
gridEvents.ItemsSource = _Audits; -
Can anybody see what's going wrong here? I get an empty grid with a blank row for each item in the ObservableCollection .
<Custom:DataGrid Width="454" Height="396" Canvas.Left="8" Canvas.Top="4" Name="gridEvents" FontWeight="Bold" FontFamily="Nina" AutoGenerateColumns="False" SelectedIndex="0" FontSize="10.667" > <Custom:DataGrid.Columns> <Custom:DataGridTextColumn x:Name="dgCol\_EVStatus" Header ="Status" FontWeight="Normal" IsReadOnly="True" /> </Custom:DataGrid.Columns> </Custom:DataGrid>
and
dgCol_EVStatus.Binding = new System.Windows.Data.Binding("Status");
ObservableCollection<RIAudit> _Audits = new ObservableCollection<RIAudit>();
_Audits.Add(auditRec);
gridEvents.ItemsSource = _Audits;redivider wrote:
AutoGenerateColumns="False"
I think you want "AutoGenerateColumns="True"" corrected spelling My bad I did not read the entire thing obviously. You don't need the Autogeneratecolumns since you describe one already. But what happens if you let the grid autogenerate the columns for you? And/or the grid might not understand how to display an RIAudit object.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here
modified on Tuesday, February 23, 2010 5:34 PM
-
Can anybody see what's going wrong here? I get an empty grid with a blank row for each item in the ObservableCollection .
<Custom:DataGrid Width="454" Height="396" Canvas.Left="8" Canvas.Top="4" Name="gridEvents" FontWeight="Bold" FontFamily="Nina" AutoGenerateColumns="False" SelectedIndex="0" FontSize="10.667" > <Custom:DataGrid.Columns> <Custom:DataGridTextColumn x:Name="dgCol\_EVStatus" Header ="Status" FontWeight="Normal" IsReadOnly="True" /> </Custom:DataGrid.Columns> </Custom:DataGrid>
and
dgCol_EVStatus.Binding = new System.Windows.Data.Binding("Status");
ObservableCollection<RIAudit> _Audits = new ObservableCollection<RIAudit>();
_Audits.Add(auditRec);
gridEvents.ItemsSource = _Audits;Hmmm.. Figured something aggravating out. RIAudit, out of necessity, uses public properties, instead of accessors. If i change
public string Status;
to
public string Status {get; set;}
then WPF is happy (though the object-ralational database i use is not). I guess I'll have write a wrapper for RIAudit, unless someone knows how to get around this. ??