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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. DataGrid Bindings not working

DataGrid Bindings not working

Scheduled Pinned Locked Moved WPF
wpfquestioncsharpwcf
3 Posts 2 Posters 10 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.
  • J Offline
    J Offline
    Jacobus01
    wrote on last edited by
    #1

    Hi, I'm currently struggling with the WPF Toolkit's DataGrid. Well just one aspect to be more accurate. I am displaying the properties of an object in their own columns on the datagrid and each property is bound to a DatagridTextColumn. But if I add a new column after the object has been instanciated and I bind to another property of the object, the binding doesn't work. The datagrid throws a NullRefferenceException. How can I work around this without having to reinstanciate the object?

    L 1 Reply Last reply
    0
    • J Jacobus01

      Hi, I'm currently struggling with the WPF Toolkit's DataGrid. Well just one aspect to be more accurate. I am displaying the properties of an object in their own columns on the datagrid and each property is bound to a DatagridTextColumn. But if I add a new column after the object has been instanciated and I bind to another property of the object, the binding doesn't work. The datagrid throws a NullRefferenceException. How can I work around this without having to reinstanciate the object?

      L Offline
      L Offline
      laprathab
      wrote on last edited by
      #2

      can you post your code...

      J 1 Reply Last reply
      0
      • L laprathab

        can you post your code...

        J Offline
        J Offline
        Jacobus01
        wrote on last edited by
        #3

        OK, This is the XAML for the Datagrid: <my:DataGrid CanUserAddRows="True" RowHeaderWidth="10" CanUserResizeRows="False" Margin="235,344,38,93" RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" HeadersVisibility="All" Name="TenderDataGrid" ItemsSource="{Binding Path=TenderLineItems}" AutoGenerateColumns="False" ColumnWidth="SizeToHeader" IsReadOnly="False" SelectionChanged="TenderDataGrid_SelectionChanged" CanUserSortColumns="False" SelectionMode="Single" SelectionUnit="CellOrRowHeader" IsSynchronizedWithCurrentItem="True" Background="#FFDDDDDD" BorderBrush="#FFAAAAAA" BorderThickness="3" AlternatingRowBackground="LightBlue">      my:DataGrid.Columns                               <my:DataGridTextColumn Header="Series" Binding="{Binding Path=Series, Mode=TwoWay}" Width="Auto"></my:DataGridTextColumn>                               <my:DataGridTextColumn Header="Item No" Binding="{Binding Path=ItemNo, Mode=TwoWay}"></my:DataGridTextColumn>                               <my:DataGridTextColumn Header="Description" Binding="{Binding Path=Description, Mode=TwoWay}" MinWidth="200"></my:DataGridTextColumn>                               <my:DataGridTextColumn Header="Unit" Binding="{Binding Path=Unit, Mode=TwoWay}"></my:DataGridTextColumn>                               <my:DataGridTextColumn Header="Quantity" Binding="{Binding Path=Qty, Mode=TwoWay}"></my:DataGridTextColumn>                               <!--<my:DataGridTextColumn Width="5000"></my:DataGridTextColumn>-->                         </my:DataGrid.Columns>                        </my:DataGrid> (Sorry about the indentation)

        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