Current filter:
                                You should refresh the page.
                                Support Center
                                  • Hi,

                                    After upgrading to the latest version I get this error in the output.

                                    System.Windows.Data Error: 17 : Cannot get 'AnimationElement' value (type 'Object') from 'DataContext' (type 'RowTypeDescriptor'). BindingExpression:Path=DataContext.AnimationElement.Color; DataItem='RowData' (HashCode=16570611); target element is 'GridRowContent' (Name='PART_DataRow'); target property is 'Background' (type 'Brush') InvalidCastException:'System.InvalidCastException: Specified cast is not valid. at DevExpress.Data.Access.UnboundPropertyDescriptor.GetValue(Object component) at DevExpress.Xpf.Data.RowTypeDescriptor.GetValueCore(DataColumnInfo info) at DevExpress.Xpf.Data.RowTypeDescriptor.GetValue(DataColumnInfo info) at DevExpress.Xpf.Data.RowPropertyDescriptor.GetValue(Object component) at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level) at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)'

                                    Here is the code I use.

                                    <local:GridColumnTemplateSelector x:Key="GridColumnTemplateSelector"/> <DataTemplate x:Key="DefaultColumnTemplate"> <ContentControl> <dxg:GridColumn AllowColumnFiltering="False" my:ColumnBindingHelper.BindingPath="{Binding Path=(dx:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}" Header="{Binding Caption}" GroupIndex="{Binding GroupIndex}" Width="{Binding Width}" AllowEditing="{Binding AllowEditing, Converter={converters:BoolToDefaultBooleanConverter}, Mode=OneWay}"> <dxg:GridColumn.EditSettings> <dxe:TextEditSettings TextWrapping="NoWrap" DisplayFormat="{Binding DisplayFormat}" AllowSpinOnMouseWheel="False" /> </dxg:GridColumn.EditSettings> </dxg:GridColumn> </ContentControl> </DataTemplate> <DataTemplate x:Key="UnboundColumnTemplate"> <ContentControl> <dxg:GridColumn FieldName="{Binding FieldName}" UnboundType="Object" Visible="{Binding IsVisible}" /> </ContentControl> </DataTemplate> <Style x:Key="RowStyle" TargetType="{x:Type ContentControl}"> <Setter Property="Background" Value="{Binding Path=DataContext.AnimationElement.Color, Converter={converters:ColorToBrushConverter}}"/> <Style.Triggers> <Trigger Property="dxg:DataViewBase.IsFocusedRow" Value="true"> <Setter Property="Background" Value="#E5EEF8" /> </Trigger> </Style.Triggers> </Style> <dxg:GridControl x:Name="gridView" IsEnabled="{Binding GridIsEnabled}" ItemsSource="{Binding PriceListLines}" ColumnsSource="{Binding GridColumns}" ColumnGeneratorTemplateSelector="{StaticResource GridColumnTemplateSelector}" > <dxg:GridControl.View> <dxg:TableView AllowMoving="false" ShowGroupPanel="false" AllowGrouping="false" AllowEditing="False" FocusedRow="{Binding SelectedPriceListLine, Mode=TwoWay}" RowStyle="{StaticResource RowStyle}" CellStyle="{StaticResource CellStyle}"/> </dxg:GridControl.View> </dxg:GridControl>

                                    private AnimationElement GetAnimationElement(long priceListLineCid) { AnimationElement element; if (!animationElements.TryGetValue(priceListLineCid, out element)) { element = new AnimationElement(); animationElements[priceListLineCid] = element; } return element; } public void GridControl_CustomUnboundColumnData(object sender, GridColumnDataEventArgs e) { if (e.Column != null && e.Column.FieldName == "AnimationElement") { e.Value = GetAnimationElement(PriceListLines[e.ListSourceRowIndex].Cid); } }

                                • Hi,

                                  Thank you for your message.

                                  It appears that this behavior is not quite correct. I will pass this ticket to our developers, so that they can investigate this shortcoming on their side. Please bear with us.

                                  In the meantime, you can resolve this issue by deleting the following line:

                                  local:ColumnBindingHelper.BindingPath="{Binding Path=(dx:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}"

                                  from the DefaultColumnTemplate and adding the following one:

                                  FieldName="{Binding FieldName}"
                                • Marcus Johansson 10.11.2012

                                  Does not work. Please see the attached image and ID:B212778

                                • Hi Marcus,

                                  Thank you for the update. Yes, we see the problem, but I am afraid we have not managed to find a solution. We will keep you informed about our progress.

                                1 Solution

                                Creation Date Rating Importance Sort by

                                Hello Marcus,
                                Thank you for your patience. To fix the problem, I suggest you change the FieldName binding in the UnboundColumnTemplate as follows:

                                <dxg:GridColumn FieldName="{Binding Path=(dx:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}" UnboundType="Object" Visible="{Binding IsVisible}" />
                                Please take a moment to try this solution and let us know of your results.

                                Show all comments
                                • Marcus Johansson 10.12.2012

                                  Does not work.

                                  System.Windows.Data Error: 17 : Cannot get 'AnimationElement' value (type 'Object') from 'DataContext' (type 'RowTypeDescriptor'). BindingExpression:Path=DataContext.AnimationElement.Color; DataItem='RowData' (HashCode=21886883); target element is 'GridRowContent' (Name='PART_DataRow'); target property is 'Background' (type 'Brush') InvalidCastException:'System.InvalidCastException: Specified cast is not valid.
                                     at DevExpress.Data.Access.UnboundPropertyDescriptor.GetValue(Object component)
                                     at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
                                     at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)'

                                • Marcus Johansson 10.15.2012

                                  Hi, yes I can see that it works in the example. But in my reale project I still get the error.
                                  I have tried to extend the example project with code from my reale code reproduce the error but can not pin point the failing code. I can not send you my full codebase becouse of all its dependcies. Can you please look at the code i attache here to see if you can see why I still get the error

                                • Hello Marcus,

                                  While looking through the files you sent to us, I noticed that you bind columns via the ColumnBindingHelper class. Would you please provide us with the source code of this class? I suspect that it causes the issue.

                                • Marcus Johansson 10.16.2012

                                  ok, here it is.

                                • Hi Marcus,

                                  Thank you for your response. You have defined the ColumnBindingHelper.BindingPath property in the following manner:

                                  public static readonly DependencyProperty BindingPathProperty = DependencyProperty.RegisterAttached("BindingPath", typeof(string), typeof(ColumnBindingHelper), new UIPropertyMetadata(null, new PropertyChangedCallback(OnBindingPathChanged)));
                                  This property has the String type, but in xaml you set this property to an object that has the Binding type:
                                  my:ColumnBindingHelper.BindingPath="{Binding Path=(dx:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}"

                                  That is why you face an error. I suggest you change the BindingPath property definition in order to make its type equal to the Binding:

                                  public class ColumnBindingHelper { public static readonly DependencyProperty BindingPathProperty = DependencyProperty.RegisterAttached("BindingPath", typeof(Binding), typeof(ColumnBindingHelper), new PropertyMetadata(null, new PropertyChangedCallback(OnBindingPathChanged))); public static string GetBindingPath(DependencyObject target) { return (string)target.GetValue(BindingPathProperty); } public static void SetBindingPath(DependencyObject target, string value) { target.SetValue(BindingPathProperty, value); } private static void OnBindingPathChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { var column = o as DevExpress.Xpf.Grid.GridColumn; column.DisplayMemberBinding = e.NewValue; } }

                                  Please let me know of your results.

                                • Hi Marcus,

                                  Please accept my sincere apologies for providing you with an incorrect solution. I have researched your scenario once again and currently, I see that the error is related to our DXGrid. We have also managed to reproduce the same problem with a simple sample.

                                  Our R&D team is researching the issue and we hope to fix it soon.

                                  As for a workaround, I suggest you do not use DisplayMemberBinding for now. Use the FieldName.

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners