i have a data grid that has a list bound to it. i added and unbounded field in the xaml but it isnt showing. i was to add two buttons in the unbounded field to delete or change a property in the row
Helo Pete,
Thank you for your post.
I have been looking into your issue. I created a sample application based on your scenario and I could not manage to reproduce the issue on my side. I have tested the sample with the latest service release of 14.1 and the UnboundField are shown. In the sample I have added a XamDataGrid that is bound to a collection and added a FieldLayout that has two UnboundFields with buttons in it and also some regular fields defined in it.
It is possible to get similar behavior that you have described, if you have a field defined in your FieldLayout than does not have a property from the DataSource that corresponds to it. In this scenario, the XamDataGrid will not use the this FieldLayout and will generate a new FieldLayout that will be used for the DataSource.
Would you please let me know if you can reproduce the same behavior with my sample application and if not, would you please modify my sample application to show the issue or send me an isolated sample application, in order to be able to research what might be the reason for the behavior?
Looking forward to hearing from you.
here is my xaml without trying to add the unbounded field, the datasource changes based upon selected entity in our software so it will have differnet fields based on what the CurrentListSource contains. however i need the buttons added to the grid regarless of the other fields.
<igDP:XamDataGrid DataSource="{Binding ElementName=summaryPanel, Path=CurrentListSource}" Name="entityGrid" AutoFit="True" RecordActivated="OnRecordActivated" MouseDoubleClick="entityGrid_MouseDoubleClick" FieldLayoutInitialized="GridFieldLayoutInitialized" GroupByAreaLocation="None" Loaded="entityGrid_Loaded"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" SelectionTypeCell="None" SelectionTypeField="None" SelectionTypeRecord="None" /> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.Resources> <ContextMenu HasDropShadow="True" x:Key="imageMenu" > <MenuItem Header="{Binding Path=Button_Delete, Source={x:Static Internationalization:CultureResources.CultureStrings}}" Command="Controls:AppCommands.MainDelete" /> <MenuItem Header="{Binding Path=ChangeStatus, Source={x:Static Internationalization:CultureResources.CultureStrings}}" Command="Controls:AppCommands.ChangeStatus"/> </ContextMenu> <Style TargetType="{x:Type igDP:DataRecordCellArea}" > <Setter Property="ContextMenu" Value="{StaticResource imageMenu}" /> <EventSetter Event="ContextMenuOpening" Handler="OnContextMenuOpening" /> </Style> </igDP:XamDataGrid.Resources> </igDP:XamDataGrid>
i think it has something to do with this
A FieldLayout defines the Fields (columns) contained in a particular DataRecord. When a DataRecord is created, the FieldLayouts collection is searched for an existing FieldLayout whose Fields match the DataItem's properties. If a FieldLayout is found, it is associated with the DataRecord; if it is not found, a new FieldLayout is created. When a new FieldLayout is created, the FieldLayoutInitializing and FieldLayoutInitialized events are raised.
If the new FieldLayout's AutoGenerateFieldsResolved property returns True, the Fields collection is automatically populated with a Field for every public property on the data item.
its like it doesnt see my unbounded field in the xaml because the field layouts are being populated automatically???
i believe i have figure out my issue, however i have a new question. i programmatically add a field to the xamdatagrid with the following style. however the event fire and act upon my active record as per the method i am calling. is there a way i can tell where the button click occured. Meaning if i click on the unbound button in row one can i tell it was click on in that row?
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="buttonFieldStyle"> <Setter Property="Visibility" Value="Visible"/> <Setter Property="Padding" Value="0"/> <Setter Property="Margin" Value="2,0,0,0"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Image Source="/DeVilbiss.SmartLink.Controls;component/Resources/CameraOrbit.png" Width="20" Height="20" Grid.Column="1" Cursor="Hand" MouseLeftButtonDown="Image_MouseLeftButtonDown_ChangeStatus" ToolTip="{Binding Path=ChangeStatus, Source={x:Static Internationalization:CultureResources.CultureStrings}}"/>
<Image Source="/DeVilbiss.SmartLink.Controls;component/Resources/delete_over.png" Width="20" Height="20" Grid.Column="2" Cursor="Hand" MouseLeftButtonDown="Image_MouseLeftButtonDown" ToolTip="{Binding Path=Button_Delete, Source={x:Static Internationalization:CultureResources.CultureStrings}}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
Hello Pette,
I have been looking into your question and I modified the sample application to show you how you can implement the functionality that you want to achieve. You can handle the click event of the button and in the event handler you can use the Utilities class to get the DataRecord of the current DataPresenter.
Please let me know if you need any further assistance on this matter.