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.
Now I use a field like this :
void xamDataGrid_FieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { //a cheat to get the number of columns to create. var lines = this.ViewModel.Lines.First();
for (Int32 i = 0; i < lines.Values.Count; i++) { var field = new Field { Name = lines.Values[i].Title };
field.AllowEdit = false;
e.FieldLayout.Fields.Add(field); } }
Values are missing and I have empty cells everywhere.
I need it before I release this update to my users.
Thank you for posting!
I have been looking into it.
It will be great if you could share a sample project that illustrates the behavior. This way I would be able to further investigate this for you and provide you with more detailed information on this matter. To upload an archive file you can choose the Options tab when you respond to a thread and click the Add/Update button. You can also create a support ticket (or I could create one on your behalf if you prefer) so that you can upload the sample and it is not public for the community.
I attach a project to test.
Values for Period X are not displayed.
Thanks for your help
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.
I am just checking if there is anything else I can do for you.
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.
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 ?