hi,
we had previously written a wrapper around the ultragrid that reflected on the attributes of the list of ITypedItem that it was bound to to format the column / hide it / set it as read only etc.
(this allowed us to easily set the format of the column by specifying an attribute on the appropriate property)
I would like to do a similar layer if possible for the xamdatagrid.
Any tips on how i could go about this?
in the ultragridcolumn we used to be able to call GetPropertyDescriptor and then go throught the attributes of that.
i see field has the GetPropertyDescripto but this required a Data Record?
any ideas if it's possible to do something similar with the xam grid
also it seems that some attributes are picked up currently (Browsable()) and DisplayName())
is there a listof currently used attributes and their functions?
Hello,
I believe there is no official documentation for which attributes are natively supported with the XamDataGrid. To the ones that you have already discover, I can add the ReadOnly attribute which will set the AllowEdit property of the field. In case you have other attributes that are not implemented, you can submit feature requests for them here.
Hi Alex,
i changed the solutiong given to just bind on the CellValuePresenter for the moment but the code doesn't seem to work:
{
)
}
the problem seems to be that the cellValuePresenter.Field is always null? do you know why that might be?
the binding code i used was as follows:
<
Style TargetType="{x:Type src:CellValuePresenter}">
Style.Triggers>
DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource ReadOnlyConverter}}" Value="False">
...
can you see any obvious issues with this?
Binding directly to the CellValuePresenter will resolve to null. What you could do is to use a MultiValueCovnerter if you want to be able to access multiple properties of the CVP (otherwise bind only to the property that you are interested). Another way, would be to use the ConvertParameter.
ok, is there any guides on multi-value convertors or how to use the convert parameters. I need to pass in the dataitem and the column name to work out if the column is read-only or not.
For more information on value converters, please follow the following links :
WPF Converters
WPF Converters in XamDataGrid
sorry, why does starting the trigger fron the cellvalue presenter cause this problem?
it seems to me that i should have access to the cellvaluepresenter's properties from my code? the record is resolving fine, but the field is null?
could you give me any sample code as to how i can pass in the column name as a parameter to my convertor as i'm a bit confused from these articles
I am attaching a sample project demonstrating the use of MultiValueConverters.
In your case, I would recommend using MultiDataTrigger instead of DataTrigger if you need to bind to multiple values.
I tried the following with no luck (the multivalue convertor is called but the values in the object[] are set to dependencyproperty value not set?
can anyone help with how to do the binding?
DataTrigger Value="False">
DataTrigger.Binding>
MultiBinding Converter="{StaticResource ReadOnlyConverter}">
Binding Path="Record.DataItem" />
Binding Path="Field.Name" />
</
MultiBinding>
</D
ataTrigger.Binding>