Hello,
I need to display an array with a random amount of headers and lines.
I can have 2 to 20 columns and 10 to 200 lines.
So I need to be able to bind a list of headers and lines, all objects are in strings.
I already have another xamDatagrid with custom xaml style, so I would like to re-use it.
Thnaks for your help.
Regards
Thank you for your post.
I have been looking into it, but it seems like I am missing something about your scenario, so if this is still an issue for you, could you please send me, an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward to hearing from you.
The context of my project is :
I have two IEnumerables with string :
IEnumerable<string> Lines { get; } IEnumerable<string> Headers { get; }
In Headers, I have : "","Header1","Header2"
In Lines, I have : "10","Value1",Value2" // "15","Value3","Value4"
I want to display the grid with Headers as heards and Lines as rows with values.
To bind Headers only for columns title, and Lines for the content.
I can't give you a little solution.
Hello ,
Thank you for your feedback.
I have been looking into the sample application that you have provided and I am not sure how exactly you want to display your inner collection(Periods). It seems that the issue that you have described is caused by your view model. You can display your data in hierarchical grid, please see the attached image. In order to be able to achieve this, you just have to set AutoGenerateFields property of XamDataGrid to true.
If you want you can use UnboundField or you can set BindingType property of Field to Unbound. In CellValuePresenterStyle of this field you can create style for CellValuePresenter and set its Template property. In in it you can create ControlTemplate with TextBlock and by using MultiBinding you can set the DataContext of TextBlock to the current item of Periods collection. I modified you sample application in order to be able to show you how you can implement this approach.
Please let me know if you need any further assistance on the matter.
The list of period is dynamic so I can't hard code it.
I don't use UnboundField because it's too old for resharper/codeMaid so I use a field.
I try to get the previous field (that is fixed) and change the title but I have an exception.
Maybe the solution is to set the style as a cellValuePresenter or as a label.
All cells are empty and I know that the collection is good.
After some tests, I keep your solution with NumericEditor.
Now, I play with xaml lines and style setter.
I saw that you have a <Trigger Property="IsInEditMode" Value="True"> in XamMaskedEditor, if I want to style it when EditMode = false to have foreground with black color, how to code it ?
I have been looking into it and I am not sure that understand what you are trying to achieve correctly. Would you please provide me with more details about what you want to style, it will be great if you could share sample project that illustrate the issue, so I will be able to further investigate it for you.
I am just checking if there is anything else I can do for you.