Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. DataGrid list binding

DataGrid list binding

Scheduled Pinned Locked Moved WPF
csswpfwcfquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redivider
    wrote on last edited by
    #1

    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;

    L R 2 Replies Last reply
    0
    • R redivider

      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;

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • R redivider

        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;

        R Offline
        R Offline
        redivider
        wrote on last edited by
        #3

        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. ??

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups