Use CellStyleSelector with in Code-behind

2 posts, 0 answers
  1. Rever
    Rever avatar
    2 posts
    Member since:
    Oct 2011

    Posted 16 Feb 2012 Link to this post

    Hello,  I have some issue.
    I need to change the cell background by condition.
    I know the CellStyleSelector can be used in xaml,but how can i use the CellStyleSelector by Code-behind?
    I have try writing some code,but it can't work.

    override SelectStyle

    public class TestStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            ExamineEty ex = item as ExamineEty;
            if (ex.Icode129>0)
                return this.LeagueStyle;
            return this.DivisionStyle;
        }
        public Style LeagueStyle
        {
            get;
            set;
        }
        public Style DivisionStyle
        {
            get;
            set;
        }
     
    }

    xaml
    <UserControl.Resources >
          <myExamine:TestStyleSelector  x:Key="TStyleSelector">
              <myExamine:TestStyleSelector.LeagueStyle>
                  <Style TargetType="telerik:GridViewRow">
                      <Setter Property="Background" Value="LightGreen" />
                  </Style>
              </myExamine:TestStyleSelector.LeagueStyle>
              <myExamine:TestStyleSelector.DivisionStyle>
                  <Style TargetType="telerik:GridViewRow">
                      <Setter Property="Background" Value="Black" />
                  </Style>
              </myExamine:TestStyleSelector.DivisionStyle>
          </myExamine:TestStyleSelector>
      </UserControl.Resources>

    Code-behind
    column = new Telerik.Windows.Controls.GridViewDataColumn();
    column.Header = "TimePoint";
    column.IsReadOnly = true;
    column.TextAlignment = TextAlignment.Center;
    column.DataMemberBinding = new System.Windows.Data.Binding("TimePoint");
    column.CellStyleSelector = this.Resources["TStyleSelector"] as StyleSelector;
    this.RgvVerify.Columns.Add(column);

    and some wrong report
    消息: Unhandled Error in Silverlight Application
    Code: 4004  
    Category: ManagedRuntimeError     
    Message: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       位于 System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       位于 System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       位于 System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       位于 System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       位于 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCellStyle(GridViewColumn column, GridViewCell cell)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells()
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       位于 System.Windows.UIElement.Measure(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0]
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       位于 System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       位于 System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       位于 System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       位于 System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       位于 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCellStyle(GridViewColumn column, GridViewCell cell)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells()
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       位于 System.Windows.UIElement.Measure(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0]
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       位于 System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       位于 System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       位于 System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       位于 System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       位于 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCellStyle(GridViewColumn column, GridViewCell cell)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells()
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       位于 System.Windows.UIElement.Measure(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0]
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       位于 System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       位于 System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       位于 System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       位于 System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       位于 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCellStyle(GridViewColumn column, GridViewCell cell)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells()
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       位于 System.Windows.UIElement.Measure(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0]
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       位于 System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       位于 System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       位于 System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       位于 System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       位于 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCellStyle(GridViewColumn column, GridViewCell cell)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells()
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       位于 System.Windows.UIElement.Measure(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) [Line: 0 Position: 0]
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
       位于 MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       位于 System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       位于 System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       位于 System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       位于 System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       位于 System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCellStyle(GridViewColumn column, GridViewCell cell)
       位于 Telerik.Windows.Controls.GridView.GridViewRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex)
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells()
       位于 Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---
       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       位于 MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
       位于 System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
       位于 Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)
       位于 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       --- 内部异常堆栈跟踪的结尾 ---


    How can i use by code-behind?
    thanks,
    rever
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Feb 2012 Link to this post

    Hello,

     Do you get he same error if you apply the CellStyleSelector in XAML?

    All the best,
    Didie
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top