Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Add User Control Dynamically to TemplateColumnLayout
posted

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>

Parents Reply Children