2011-11-25 26 views
1

在WPF Datagrid中,如果使用了行樣式,則它不檢測網格行。如果我刪除行樣式,它會正確檢測單元格和行。wpf datagrid中的編碼UI測試在應用行樣式時無法識別單元格和行

<DataGrid Grid.Row="1" x:Name="c_dataGrid" 
     ItemsSource="{Binding DataSource}" 
     AutoGenerateColumns="True" 
     RowStyle="{StaticResource rowStyle}"> 
    <DataGrid.ItemContainerStyle> 
    <Style> 
     <Setter Property="AutomationProperties.Name" Value="{Binding Id}"/> 
    </Style> 
    </DataGrid.ItemContainerStyle> 
</DataGrid> 

<Style x:Key="rowStyle" TargetType="{x:Type DataGridRow}" 
    <Setter Property="Foreground" Value="Green"/>  
</Style> 
+1

你是什麼意思「檢測」? – Juan

+0

它無法識別數據網格行。它只是說「由於控件沒有任何好的識別屬性,因此沒有記錄對列表項的最後操作」。 – John

+1

編碼的UI測試是聖盃。然而,我不認爲我們在那裏。由於該控件沒有任何良好的識別屬性,所以「沒有記錄最後一次對列表項的操作」。錯誤信息足以驅使好的開發者發瘋。 –

回答

0

在這裏瞎猜? 這有什麼區別,如果你申請的支持算法FMP財產?

<Style 
    x:Key="rowStyle" 
    TargetType="{x:Type DataGridRow}" 
    BasedOn="{StaticResource {x:Type DataGridRow}}"> 
    <Setter Property="Foreground" Value="Green"/>  
</Style> 
相關問題