Hi Mohanrma A.,
please find the attached visualization of what
I am aiming for.
There seems to be a slight misunderstanding:
there is no problem with the varying number of rows, this is working correctly.
The number of columns in the VisibleElements will vary, which is why they cannot be hardcoded. In the beginning, there will be no members in the VisibleElements. Later there will be some members added and for each row there will be different values. Think of the VisibleElement columns as measurements. In the beginning there is no data. Then you perform a measurement and add the data in the first column of VisibleElements. For each DataGridRowElement there will be a different value. The next measurement data is then displayed in the second column of VisibleElements, and so on.
The entries in the VisibleElements belong to each row, that’s why they are a child property of said row. The row properties of standard deviation, average etc. are based on the members of VisibleElements for each row.
I hope this explanation is helpful for understanding the situation, if you have additional questions please ask.
Regards,
Ole Valler
|
var visibleElementCount = 0;
foreach(var item in itemsSourceCollection)
{
if (item.VisibleElements.Count > visibleElementCount)
visibleElementCount = item.VisibleElements.Count;
}
for (int i = 0; i < visibleElementCount; i++)
{
this.dataGrid.Columns.Add(new GridTextColumn()
{
MappingName = "VisibleElements[" + i + "].Content",
UseBindingValue = true,
});
} |
|
for (int i = 0; i < visibleElementCount; i++)
{
this.dataGrid.Columns.Add(new GridTextColumn()
{
MappingName = "VisibleElements[" + i + "].Content",
UseBindingValue = true,
DisplayBinding = new Binding() { Converter = new AnalysisDecimalToStringConverter(), Path = new PropertyPath("VisibleElements[" + i + "].Content") }
});
} |
|
<Page.Resources>
<local:ColumnNameToColumnIndexConverter x:Key="ColumnNameToColumnIndexConverter"/>
<DataTemplate x:Key="headerTemplate">
<StackPanel>
<Button Width="40" Content="X" Command="{Binding }" />
<CheckBox Width="40" IsChecked="True" Content="{Binding Converter={StaticResource ColumnNameToColumnIndexConverter}}"/>
</StackPanel>
</DataTemplate>
</Page.Resources>
for (int i = 0; i < visibleElementCount; i++)
{
this.dataGrid.Columns.Add(new GridTextColumn()
{
MappingName = "VisibleElements[" + i + "].Content",
UseBindingValue = true,
DisplayBinding = new Binding() { Converter = new AnalysisDecimalToStringConverter(), Path = new PropertyPath("VisibleElements[" + i + "].Content") },
HeaderTemplate = this.Resources["headerTemplate"] as DataTemplate
});
}
public class ColumnNameToColumnIndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var splitedItems = value.ToString().Split(new char[] { '[', ']' });
return splitedItems[1];
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
} |
<DataTemplate x:Key="headerTemplate" x:DataType="local:VisibleElement>
<StackPanel>
<Button Width="40" Content="X" Command="{Binding}" CommandParameter="{Binding ColumnIndex}" />
<CheckBox Width="40" IsChecked="{Binding IsChecked, Mode=TwoWay}" Content="{Binding ColumnIndex}"/>
</StackPanel>
</DataTemplate>
<syncfusion:GridTextColumn MappingName="OrderID">
<syncfusion:GridTextColumn.CellStyle>
<Style TargetType="syncfusion:GridCell">
<Setter Property="utils:SetterValueBindingHelper.PropertyBinding">
<Setter.Value>
<utils:SetterValueBindingHelper Property="Background" Binding="{Binding OrderID,Converter={StaticResource converter}}"/>
</Setter.Value>
</Setter>
</Style>
</syncfusion:GridTextColumn.CellStyle>
</syncfusion:GridTextColumn>
in CodeBehind. I cant do it in Xaml as the column mappings are variable. How do I achieve this?