我希望找到一个关于从WPF工具包2010自定义Datagrid的答案。我想在数据网格的DataGridColumnHeaderPresenter上面添加一个TITLE区域。问题是我希望它作为用户控件或数据模板,我可以从XML填充标题。我希望在一个页面上为多个数据网格提供唯一标题,从一个XML获取数据。我在同一个窗口中填充了一些数据网格。对于从XML填充并限制到每个数据网格以避免出版的内容,可以添加可自定义的Tile区域的最佳解决方案是什么?
提前谢谢你。我以这种方式生成带有列的datagrid:
<Custom:DataGrid Grid.Column="0" Grid.Row="1" x:Name="ServerList" ItemsSource="{Binding Source={StaticResource PagesData}, XPath=ListTiles/Tile1}">
<Custom:DataGrid.Columns>
<Custom:DataGridTextColumn Header="Name" Binding="{Binding XPath=@Name}" />
<Custom:DataGridTextColumn Header="Status" Binding="{Binding XPath=@Status}" />
<Custom:DataGridTextColumn Header="Events" Binding="{Binding XPath=@Events}" />
<Custom:DataGridTextColumn Header="Services" Binding="{Binding XPath=@Services}" />
</Custom:DataGrid.Columns>
<Custom:DataGrid x:Name="Events" Grid.Column="0" Grid.Row="2" ItemsSource="{Binding Source={StaticResource PagesData}, XPath=ListTiles/Tile2}" >
<Custom:DataGrid.Columns>
<Custom:DataGridTextColumn Header="Name" Binding="{Binding XPath=@Name}" />
<Custom:DataGridTextColumn Header="Level" Binding="{Binding XPath=@Level}" />
<Custom:DataGridTextColumn Header="Source" Binding="{Binding XPath=@Source}" />
<Custom:DataGridTextColumn Header="In last 24h" Binding="{Binding XPath=@TimeSpan}" />
</Custom:DataGrid.Columns>
<Custom:DataGrid x:Name="Services" Grid.Column="2" Grid.Row="2" ItemsSource="{Binding Source={StaticResource PagesData}, XPath=ListTiles/Tile3}">
<Custom:DataGrid.Columns>
<Custom:DataGridTextColumn Header="Name" Binding="{Binding XPath=@Name}" />
<Custom:DataGridTextColumn Header="Status" Binding="{Binding XPath=@Status}" />
<Custom:DataGridTextColumn Header="Start" Binding="{Binding XPath=@Start}" />
</Custom:DataGrid.Columns>
XML:
<?xml version="1.0" encoding="utf-8"?>
<ListTiles xmlns="">
<Tile1>
<Header Title="ROLES & GROUPS" />
<Server Name="Kim" Status="ready" Events="1" Services="1" />
<Server Name="Sherri" Status="past" Events="2" Services="1"/>
<Server Name="Mike" Status="future" Events="3" Services="1" />
</Tile1>
<Tile2>
<Header Title="EVENTS" />
<Server Name="Young" Level="average" Source="home" TimeSpan="5" />
<Server Name="Sarah" Level="Critical" Source="work" TimeSpan="6" />
<Server Name="Susan" Level="normal" Source="friend" TimeSpan="2" />
</Tile2>
<Tile3>
<Header Title="SERVICES" />
<Server Name="Josh" DisplayName="FF" Status="Running" Start="Auto" />
<Server Name="Amy" DisplayName="DD" Status="Rest" Start="Auto" />
<Server Name="Bill" DisplayName="AS" Status="Work" Start="Auto" />
</Tile3>
</ListTiles>