http://wiki.blender.org/index.php/Game_Engine
Игровой Механизм Блендера является 3D средой разработки игр с основанной на Python системой 'AI'.
Благодаря ответу @Aran, а также паре сообщений, которые я нашел в обсуждениях Codeplex (см. http://wpf.codeplex.com/Thread/View.aspx?ThreadId=65069 ), мне удалось приехать с набором стилей, который позволяет установить фон строки заголовка без отказа от функциональности (стрелки сортировки, разделители и т. д.).
Единственным исключением из этого правила является функция «выбора ячейки». DataGrid имеет свойство SelectionUnit
, которому можно присвоить значение Cell, FullRow или CellOrRowHeader, но оно, похоже, не работает. Если я установил его на FullRow
(который должен только выбрать всю строку независимо от того, где вы щелкаете по этой строке), он все равно визуально выбирает отдельные ячейки, когда вы нажимаете на них. На изображении ниже показан пример DataGrid (без применения стиля), где SelectionUnit = "FullRow"
. Как видите, похоже, что выделена ячейка (строка G столбца Name). Поскольку в настоящее время мне не нужно выделять ячейки, я разработал свои стили для подавления этой темно-черной границы, которая появляется вокруг ячейки при щелчке по ней.
alt text http://img80.imageshack.us/img80/4757/datagriddefaultcellsele. jpg
Вот пример стилизованного DataGrid, отсортированного по убыванию по идентификатору. Как видите, рядом с ярлыком идентификатора появляется стрелка вниз, размер столбца автоматически изменяется, чтобы освободить место для стрелки сортировки.
alt text http://img377.imageshack.us/img377/3836/datagridcustomfixed.jpg
Вот еще один пример стилизованной DataGrid. Это сортируется по возрастанию по «Сохранено?». Обратите внимание, что заголовок центрирован, но по обе стороны от него остается достаточно места для стрелки сортировки.
alt text http://img203.imageshack.us/img203/5140/datagridcustomfixed2.jpg
Кисти
В этих стилях есть несколько настроек кисти, все они имеют вид Property = "{StaticResource Media _...}"
. Я собираюсь пока опустить определения, потому что мне потребуется некоторое время, чтобы скомпилировать их все, но если кто-то заинтересован в дублировании точных цветов, которые я использовал, оставьте комментарий. включая стиль заголовка столбца и стиль ячейки, которые определены выше)
<Style
x:Key="DataGrid_Style"
TargetType="wt:DataGrid">
<Setter
Property="ColumnHeaderStyle"
Value="{StaticResource DataGrid_ColumnHeaderStyle}" />
<Setter
Property="CellStyle"
Value="{StaticResource DataGrid_CellStyle}" />
<Setter
Property="RowBackground"
Value="{StaticResource Media_OddRowBackgroundBrush}" />
<Setter
Property="AlternatingRowBackground"
Value="{StaticResource Media_EvenRowBackgroundBrush}" />
<Setter
Property="HorizontalGridLinesBrush"
Value="LightGray" />
<Setter
Property="VerticalGridLinesBrush"
Value="LightGray" />
<Setter
Property="SelectionMode"
Value="Single" />
<Setter
Property="SelectionUnit"
Value="FullRow" />
<Setter
Property="AutoGenerateColumns"
Value="False" />
<Setter
Property="CanUserAddRows"
Value="False" />
<Setter
Property="CanUserDeleteRows"
Value="False" />
<Setter
Property="CanUserReorderColumns"
Value="True" />
<Setter
Property="CanUserResizeColumns"
Value="True" />
<Setter
Property="CanUserResizeRows"
Value="False" />
<Setter
Property="CanUserSortColumns"
Value="True" />
<Setter
Property="IsReadOnly"
Value="True" />
<Setter
Property="HeadersVisibility"
Value="Column" />
</Style>
Пример DataGrid с использованием этих стилей
(примечание: для работы требуются резервные данные - файл XML)
<wt:DataGrid
Style="{StaticResource DataGrid_Style}"
Margin="0,5,0,0"
ItemsSource="{Binding Source={StaticResource Main_ContactData}, XPath=//Contacts/*}">
<wt:DataGrid.Columns>
<wt:DataGridTextColumn
Binding="{Binding XPath=@Letter}"
Header="ID" />
<wt:DataGridTextColumn
Binding="{Binding XPath=@Name}"
Header="Name" />
<wt:DataGridTextColumn
HeaderStyle="{StaticResource DataGrid_CenteredColumnHeaderStyle}"
CellStyle="{StaticResource DataGrid_CenteredCellStyle}"
Binding="{Binding XPath=@IsSaved}"
Header="Saved?" />
<wt:DataGridTextColumn
HeaderStyle="{StaticResource DataGrid_CenteredColumnHeaderStyle}"
CellStyle="{StaticResource DataGrid_CenteredCellStyle}"
Binding="{Binding XPath=@IsBackedUp}"
Header="Backed Up?" />
</wt:DataGrid.Columns>
</wt:DataGrid>
try putting
<Style
x:Key="DataGrid_Style"
TargetType="wt:DataGrid"
BasedOn="{StaticResource {x:Type wt:DataGrid}}">
to base your style on the current datagrid one, and the same for the headers
<Style
x:Key="DataGrid_ColumnHeaderStyle"
TargetType="wt:DataGridColumnHeader"
BasedOn="{StaticResource {x:Type wt:DataGridColumnHeader}}">
scratch the above - i pulled your style down to the offending element
<Style
TargetType="wt:DataGridColumnHeader"
BasedOn="{StaticResource {x:Type wt:DataGridColumnHeader}}">
<Setter
Property="Background"
Value="Blue" />
</Style>
if you set the background (or the border brush ) you're screwed.
I found this link on code project, to back this up -
"The style of the column header can easily be modified via the ColumnHeaderStyle of the DataGrid. However, if you modify the background colour of the column header, you will find that the sort arrows disappear! This is because the arrows are not part of the ColumnHeader template; instead, they are added programmatically."
he has a style that re-adds the sort indicators.
i have had a look at the code for DataGridHeaderBorder (which is the border of the datagridrowheader) which does not have its own control template, it simply derives from border. As well as the seperators being added programatically (the separators are just rectangles see line 1199 of DataGridHeaderBorder.cs) the sort indicators are. the brief look at the code that i had would suggest they should still get drawn but they dont, a step thru of the code is in order.
The solution is to override the control template i think, and add them yourself, the link on code project will get you started.