Welcome to the Xceed Community Sign in | Join | Help
Community Search  

DataGridControl - DataTrigger - style DataRow

Sort Posts: Previous Next
  •  08-08-2008, 9:30 AM Post no. 13963

    DataGridControl - DataTrigger - style DataRow

    I have read this post: http://xceed.com/CS/forums/post/7583.aspx  and tried it on my grid.

     

    I have an ID column, which is sometime -1.  My DataContext class has an ObservableCollection<> called LotList. 

     LotList has a property ACISLotId.

    • LotListViewModel (DataContext for the page)
      • LotList
        • ACISLotId (column)

     When using the following code: 

             <xcdg:DataGridControl  ItemsSource="{Binding Path=LotList}"  .....
                       .........
                <xcdg:DataGridControl.Resources>
                        <Style TargetType="{x:Type xcdg:DataRow}">
                            <Style.Triggers>
                                <!-- Currently spitting out errors but is working.-->
                                <DataTrigger  Binding="{Binding Path=ACISLotId}"
                                               Value="-1">
                                    <Setter Property="Background">
                                        <Setter.Value>
                                            <SolidColorBrush Color="BurlyWood"/>
                                        </Setter.Value>
                                    </Setter>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                </xcdg:DataGridControl.Resources>

    ........

    <xcdg:DataGridControl.Columns >
    <xcdg:Column FieldName="ACISLotId"                Title="Id"                Visible="False" />

     ........

     I get the following error: 

    BindingExpression path error: 'ACISLotId' property not found on 'object' ''LotListViewModel' (HashCode=17792110)'. BindingExpression:Path=ACISLotId; DataItem='LotListViewModel' (HashCode=17792110); target element is 'DataRow' (Name=''); target property is 'NoTarget' (type 'Object')

     So, from this - its thinking ACISLotId is on the DataContext root, but in fact its lower on the tree: 

     
    I'm not sure how to bind the trigger correctly.  

     Note that the above code DOES WORK, but it spits out an exception (above) for every line of the grid, which consumes resources and makes it really slow. 


    How can i fix this so it stops throwing exceptions?

    And if you have an answer, could you please supplement it with why this binding works AND throws an exception?  I thought bindings - if they didn't find what they are looking for at the current level would go UP the tree.. not down it. 

     Thanks

    Brett

     

     

  •  10-18-2008, 5:19 AM Post no. 16213 in reply to 13963

    Re: DataGridControl - DataTrigger - style DataRow

    I have same problem as you described. It seems to me as this only happens when DataRows are created - at first, their DataContext is set to root (grid control) DataContext and changed to appropriate row DataContext afterwards.

    Is this behaviour identified as a bug, or is it intended behavour? Is there any way to change row style in such way that it would only be applied to rows with appropriate type of DataContext, so no exceptions would be thrown?

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.