나를 용서하십시오. 그냥 초보자를 WPF
으로 용서하십시오.속성을 설정하면 System.Windows.FrameworkElement.Style 예외가 throw되었습니다.
내 작은 WPF
응용 프로그램을 VS2012
에서 디버깅하려고 할 때 예외가 발생했습니다. 아래 스크린 샷을 검토하십시오. 나는 예외가 정확히 무엇인지 알아 내려고 노력했다. 그러나 예외에 대한 자세한 메시지를 얻을 수있는 방법을 찾지 못했습니다. 코드는 XAML
의 첫 번째 줄에서 끊어지는 것처럼 보입니다.
나는 그것은 내 스타일
DataGridDemoStyle
에 나쁜 코드에 의해 발생할 수 있습니다 생각했다. 하지만 어떤 코드가 오류인지 알지 못했습니다. 오류의
InnerException
과 같은 세부 정보를 볼 방법이 있습니까?
감사합니다.
업데이트 내가 라인으로 스타일 코드 라인을 확인 후
.
DataGridDemoRowStyle
이라는 스타일이 오류를 일으켰습니다. 왜이 스타일로 인해 오류가 발생하는지 알 수 없습니다. 왜냐하면 제가 그것을 제거하기 때문입니다. 오류가 사라집니다. 아래에서 검토하십시오.
<Style x:Key="DataGridDemoStyle" TargetType="{x:Type DataGrid}">
<!--<Setter Property="AlternatingRowBackground" Value="{StaticResource RowBackgroundAlternateBrush}" />-->
<!--<Setter Property="BorderBrush" Value="#FF688CAF"/>-->
<!--<Setter Property="Background" Value="{DynamicResource bearBrush}" />-->
<!--<Setter Property="ColumnHeaderHeight" Value="50" />-->
<!--<Setter Property="HeadersVisibility" Value="All" />-->
<!--<Setter Property="RowBackground" Value="{StaticResource RowBackgroundBrush}" />-->
<!--<Setter Property="AlternationCount" Value="4" />-->
<Setter Property="RowStyle" Value="{StaticResource DataGridDemoRowStyle}" />
<!--<Setter Property="RowHeaderWidth" Value="50" />-->
<Setter Property="RowHeight" Value="22" />
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource DataGridHorizontalLinesBrush}" />
<Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle}" /><!---->
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DatagridColumnHeaderCustomTemplateStyle}" />
</Style>
<!--I don't know why below style will cause the error. If I remove it . the error will gone.-->
<Style x:Key="DataGridDemoRowStyle" TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="AlternationIndex" Value="2" >
<Setter Property="Background" Value="{StaticResource RowBackgroundAlternationIndex2Brush}" />
</Trigger>
<Trigger Property="AlternationIndex" Value="3">
<Setter Property="Background" Value="{StaticResource RowBackgroundAlternationIndex3Brush}" />
</Trigger>
</Style.Triggers>
</Style>
DataGridDemoRowStyle
스타일에 문제가 있습니까? 감사.
정확합니다. 주문 문제. –
내 질문을 검토해 주셔서 감사합니다. 좋은 하루 되세요. :) –
괜찮습니다. +1. –