Hello!
We need to show a button within a single cell. This depends on the bound field. If the bound object is of a certain type, a button needs to be shown. But this cannot be set for the field (column) because this may happen only once in a column and once in a row.
I was playing around with CellValuePresenter, but I was not able to change the control within the cell.
I did not find a solution? Does anyone has an idea?
Thanks in advance!
Florian
Thanks for your quick reply and thanks for the good answer!
Florian,
Yes, you can achieve 1 and 2 in one event. You have to use the AssignFieldLayoutToItem event. There are couple of properties in the event args that can help you determine which field layout you want to assign to that item. Define all of the fieldlayouts in the xaml (as you have done) and then assign them accordingly in this event (e.FieldLayout = ... ).
Hi Alex,
thanks, that's the solution. But let me ask two more questions on this:
1. How can I assign which field layout is used for which class?
2. Is there a way to hide the addtional column headers that are shown in the middle of the grid? We only want to have one header at the top of the grid.
Thanks, Florian
Hello Florian,
I am attaching your project back to you modified.
In your sample, you have two instances of different classes, which means that the XDG will create two field layouts. You are using AutoGenerateFields-false so you need to create two field layouts. In your sample you have created only one, and this is why the style is not applied. The other seems to be the DynamicResource markup ext.
Hey Alex!
Please find the sample project attached.
I create a mixed list of DataObjectInt and DataObjectString. The list is attached to the DataSource property of the XamDataGrid.
The grid should display the DataObjectInt as a label with a blue background. Is not working!
The DataObjectString should displayed as a button. Is also not working. For the sake of simplicity I added a property "ShowButton" to the data objects. But in my real world scenario, the decision whether the cell is displayed as button or not needs to be made depending on the type of the data object.
Thanks for further assistance,