Hi. We are using a XamGrid with a TemplateColumnLayout. Upon clicking the expander, we would like to populate the datatemplate with a user control from the code behind so we can swap out user controls dynamically.
I am currently subscribing to the "OnRowExpansionChanging" event, but can't seem to populate the cells with any content:
private void ResultsXamGrid_OnRowExpansionChanging(object sender, CancellableRowExpansionChangedEventArgs e) { e.Row.Cells[6].Content = new AddEditPlanting(); }
I would also like to get at the "Key" for the TemplateColumnLayout so I can pass that into the constructor of my usercontrol.
Thanks for your help.
<ig:XamGrid Name="ResultsXamGrid" Grid.Row="0" Grid.Column="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" ActiveItem="{Binding Path=SelectedCurrentField,Mode=TwoWay}" AutoGenerateColumns="False" ItemsSource="{Binding Path=AvailableCurrentFields}"> <ig:XamGrid.ColumnChooserSettings> <ig:ColumnChooserSettings AllowColumnMoving="True" AllowHiddenColumnIndicator="False" AllowHideColumnIcon="False" /> </ig:XamGrid.ColumnChooserSettings> <ig:XamGrid.EditingSettings> <ig:EditingSettings AllowEditing="Cell" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True" /> </ig:XamGrid.EditingSettings> <ig:XamGrid.Columns> <ig:TextColumn Key="CurrentFieldNumber" HeaderText="Field" IsReadOnly="True" />
<ig:TextColumn Key="GrowerName" HeaderText="Grower" IsReadOnly="True" />
<ig:TemplateColumnLayout Key="CurrentFieldId"> <ig:TemplateColumnLayout.Template> <DataTemplate> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> <Grid> </Grid> </ScrollViewer> </DataTemplate> </ig:TemplateColumnLayout.Template> </ig:TemplateColumnLayout>
</ig:XamGrid.Columns> </ig:XamGrid>
HI,
I am attaching a sample that dynamically loads the usercontrols of a TemplateColumnLayout.
In the code behind of the "MainWindow" file, you have commented out all of the code. Is that by design? I do not see in your code how I can programatically add a user control (or really any control) to the Template Column Layout.
Should I be trying to fill the content of a childband?
HI ,
I am doing it with a binding.
Check the template, I am using a binding on the visibility property on each usercontrol
Please let me know if you need further assistance regarding this issue.
You may want to look into placing a content presenter in the Template's datatemplate and then using a ContentTemplateSelector to determine which user control should fill the content
Matt -
Thanks! Yep, I saw that. We have it working that way too, but I would love to actually create the usercontrol via the code behind and add it to the grid through code only (nothing on the xaml page).
Any ideas on how to do that?