I am displaying a 2-level data on xamDataGrid and record selector has been replaced with checkbox. anyway to increase the indent of child level.
Hello,
You can create a style for the DataRecordPresenter and set the Left Margin. If you don't set a x:key of the style, it will be applied to all of the DataRecordPresenter including the parent Records, and the there will be a margin as well. If you do set x:key, you have to apply this style to the records you choose ( child records ).
<Style TargetType="{x:Type igDP:DataRecordPresenter}" BasedOn="{x:Null}">
<Setter Property="Margin" Value="20,0,0,0"/>
</Style>
Alex.
Alex,
I tried your way but seems like it doesn't work...I attached my codes. can u pls take a look.
Thanks a lot.
<igDP:XamDataGrid Grid.Row="1" x:Name="xamDataGrid" Theme="Aero" AutoFit="False" ContextMenu="{x:Null}" SnapsToDevicePixels="True" ScrollingMode="Immediate" AllowDrop="True" RecordContainerGenerationMode="Recycle" CellContainerGenerationMode="Recycle" RecordLoadMode="LoadOnDemand" Background="Gray" DragOver="OnDragOver" Drop="OnDataDrop" PreviewMouseDown="OnXamDataGridPreviewMouseDown" PreviewMouseMove="OnXamDataGridPreviewMouseMove" PreviewMouseUp="OnXamDataGridPreviewMouseUp" MouseDoubleClick="OnGridMouseDoubleClick" MouseRightButtonDown="OnGridMouseRightButtonDown" IsGroupByAreaExpanded="False"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:RecordSelector}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:RecordSelector}"> <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Path=DataItem.IsChecked}" Checked="OnChecked" Unchecked="OnUnChecked" > </CheckBox> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Setter Property="Margin" Value="80,0,0,0"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings DataRecordSizingMode="SizedToContentAndIndividuallySizable" AutoGenerateFields="True" RecordSelectorLocation="LeftOfCellArea" ResizingMode="Default" SelectionTypeRecord="Extended" SelectionTypeField="Extended" DataRecordPresenterStyle="{StaticResource headerStyle}" DataRecordCellAreaStyle="{StaticResource rowStyle}" SelectionTypeCell="Extended"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" CellClickAction="SelectRecord" CellMinWidth="0" AllowCellVirtualization="true" CellValuePresenterStyle="{StaticResource cellStyle}" LabelPresenterStyle="{StaticResource columnStyle}"/> <!--CellValuePresenterStyle="{StaticResource cellStyle}"--> </igDP:XamDataGrid.FieldSettings> </igDP:XamDataGrid>
I am not sure that will do the trick. The margins are respectively (left, top, right, bottom) and this way you will set the top margin of the parent record. Another way to do this is to rezise the first column. Here is what I mean:
In the beginning, all of the records (parent and child) are lined up. Then you push the child record to the right with, let's say 20. So, if you resize the first cell ( take out 20 of its ActualWidth) the rest of the fields will line up again. Will this work in your scenario?
Actually I meant (0,0,20,0) not (0,20,0,0). Sorry about confusing.
About your way (decrease the first column of child row) which point can I do this? I mean in XMAL or code-behide? If Code-behide any event-handler you suggest?
Many Thanks
If you will not be changing this cell's width, you can set it in the XAML. If you need to change it in runtime, you can use InitializeRecord event.
I wrote handler as below...But it doesn't work...any idea?
Thanks
void OnInitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e) { DataRecord dr = e.Record as DataRecord; if (dr != null && dr.ParentRecord != null) dr.Cells[0].Field.Settings.LabelWidth = dr.Cells[0].Field.Settings.LabelWidth - 20; }
also tried cellwidth...no luck...guess the way i set width of cell is wrong?
tried both but still no luck.....I ended up change margin of recordselector in code.
Try changing both like CellWidht and LabelWidth
Note: make sure you have defined the fields and CellWidth and LabelWidth in the xaml, otherwise these numbers will be NaN and nothing will happen.