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
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.
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?
I am not sure how your project is set up, but you can take a look at the attached solution of one way to do this.
thanks Alex,
any word on being able to write a custom layer to pull up the attributes of my properties manually and format my xamgrid?
We used to create all kinds of custom descriptors for
column sort order
column format (for money, numerical formats etc.)
which was great as it was all reusable on our grids throughout the app...
these aren't standard attributes though.
the other thing was do the attributes do you support Dynamic Attributes in C#
i.e.something like http://geekswithblogs.net/abhijeetp/archive/2009/01/10/dynamic-attributes-in-c.aspx
this would be useful as we need to programatically set the readonly property based on values on the bound item.
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.