如何在WPF中的Devexpress工具上在Grid(嵌套网格)中使用Grid [英] How to use Grid inside Grid (Nested Grid) on Devexpress tools in WPF
问题描述
我被困在这里,如何在devexpress网格控件上使用嵌套网格.我进行了大量研究,但找不到任何好方法.这是我的
I am stuck here that how i can use nested grid on devexpress grid control.I research alot but couldn't find anything good.Here is my
XAML
<dxdo:LayoutPanel Caption="Photography Jobs" AllowClose="False" Name="pnlShotoJobs" GotFocus="pnlShotoJobs_GotFocus">
<my:GridControl Name="dgPhotoJobs" MouseDoubleClick="dgPhotoJobs_MouseDoubleClick">
<my:GridControl.Columns>
<my:GridColumn FieldName="JobName" Name="grdColumnJobName" />
<my:GridColumn FieldName="JobDate" Name="grdColumnJobDate" />
</my:GridControl.Columns>
<my:GridControl.View>
<my:TableView NavigationStyle="Row" ShowAutoFilterRow="True" ShowGroupPanel="False" MultiSelectMode="Row" Name="JobTableView" MouseUp="JobTableView_MouseUp" AllowEditing="False" Focusable="False">
</my:TableView>
</my:GridControl.View>
</my:GridControl>
</dxdo:LayoutPanel>
设计
当我们单击任何Photography Jobs
时,将在该单击的行下方打开一个新网格,并具有属于该单击行的主键ID的所有数据.
如果您有任何代码或建议,请与我分享.
When we click on any Photography Jobs
then a new grid will open underneath that clicked row and have all the data that belongs to Primary key ID of clicked row.
IF you have any code or any advice then please share it with me.
谢谢.
推荐答案
要显示GridControl行的嵌套网格,请定义DataRowTemplate.像这样:
To show a nested grid for your GridControl rows define DataRowTemplate. like this:
<my:GridControl Name="dgPhotoJobs" MouseDoubleClick="dgPhotoJobs_MouseDoubleClick">
<my:GridControl.Columns>
<my:GridColumn FieldName="JobName" Name="grdColumnJobName" />
<my:GridColumn FieldName="JobDate" Name="grdColumnJobDate" />
</my:GridControl.Columns>
<my:GridControl.View>
<my:TableView NavigationStyle="Row" ShowAutoFilterRow="True" ShowGroupPanel="False" MultiSelectMode="Row" Name="JobTableView" AllowEditing="False" Focusable="False">
<dxg:TableView.DataRowTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<core:MeasurePixelSnapper>
<ContentPresenter ContentTemplate="{DynamicResource {dxgt:GridRowThemeKey ResourceKey=DataRowTemplate}}" Name="defaultRowPresenter" />
</core:MeasurePixelSnapper>
<core:DXExpander HorizontalExpand="None" IsExpanded="{Binding Path=(dxg:DataViewBase.IsFocusedRow), RelativeSource={RelativeSource TemplatedParent}}" VerticalExpand="FromTopToBottom">
<Border Background="Cyan" BorderBrush="{DynamicResource {dxgt:GridRowThemeKey ResourceKey=GridDataRowDelimiterBrush}}" BorderThickness="0,1,0,0" TextElement.Foreground="Black">
<Grid MaxHeight="400">
<dxg:GridControl Grid.Row="1" AutoPopulateColumns="False" ItemsSource="{Binding Path=DataContext.MyCollection, UpdateSourceTrigger=PropertyChanged}" >
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Column1" FieldName="FieldName1" AllowEditing="False"/>
<dxg:GridColumn Header="Column2" FieldName="FieldName2" AllowEditing="False">
</dxg:GridControl.Columns>
</dxg:GridControl>
</Grid>
</Border>
</core:DXExpander>
</StackPanel>
</DataTemplate>
</dxg:TableView.DataRowTemplate>
</my:TableView>
</my:GridControl.View>
</my:GridControl>
这是我的xml名称空间:
here is my xml namespaces:
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
xmlns:core="http://schemas.devexpress.com/winfx/2008/xaml/core"
这篇关于如何在WPF中的Devexpress工具上在Grid(嵌套网格)中使用Grid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!