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
1385
XamTabControl ContentTemplate messes up XamDataGrid with multiple tabs
posted

I have some code like this:

<igControls:XamTabControl ItemsSource="{Binding PricingTables, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"

SelectedIndex="{Binding SelectedIndex}"
Theme="Office2013"
local:SendMouseWheelToParent.IsSendingMouseWheelEventToParent="True">
<igControls:XamTabControl.PostTabItemContent>
<Button Grid.Column="1"
Content="Add"
ToolTip="Create a new conditional pricing table"
Command="{Binding AddConditionalPriceTableCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" />
</igControls:XamTabControl.PostTabItemContent>
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PricingTableName}" />
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="1"
Margin="5">
<!-- This is the sidebar -->
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<CheckBox Grid.Row="0"
IsChecked="{Binding IsIncluded}"
Content="Use This Table" />
<CheckBox Grid.Row="1"
IsChecked="{Binding DisplayLevelIndices}"
VerticalAlignment="Center"
VerticalContentAlignment="Center">Display Level Indices</CheckBox>
<Button Grid.Row="3"
Margin="0,10,0,0"
HorizontalAlignment="Left"
Command="{Binding DataContext.RemovePricingTableCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}} }"
CommandParameter="{Binding}"
ToolTip="Deletes this conditional pricing table permanently"
ToolTipService.ShowOnDisabled="True">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource DeleteIcon}"
Stretch="Uniform"
Height="12"
Margin="0,0,5,0" />
<TextBlock VerticalAlignment="Center">Delete This Table</TextBlock>
</StackPanel>
</Button>
</Grid>
<Grid Grid.Column="0"
FlowDirection="LeftToRight"
HorizontalAlignment="Left">
<igControls:XamDataGrid DataSource="{Binding ConditionalPriceRows, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AutoFit="False"
FieldLayoutInitialized="DataPresenterBase_OnFieldLayoutInitialized"
Tag="{Binding ExternalReadOnly, Mode=OneTime}">
<i:Interaction.Behaviors>
<local:EditModeOnTypeBehavior />
<local:ClipboardBehavior PasteAddsRows="False"
ShowErrorOnReadOnlyPaste="False" />
<local:CellUpdateDirtyBehavior />
</i:Interaction.Behaviors>
<igControls:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="True"
AllowDelete="False"
AllowAddNew="False"
AllowFieldMoving="No"
AllowClipboardOperations="All"
RecordSelectorNumberStart="1"
RecordSelectorNumberType="VisibleIndex"
HeaderPrefixAreaStyle="{StaticResource HeaderPrefixStyle}" />
</igControls:XamDataGrid.FieldLayoutSettings>
</igControls:XamDataGrid>
</Grid>
</Grid>
</DataTemplate>
</TabControl.ContentTemplate>
</igControls:XamTabControl>

What I'm trying to do is have multiple tabs, each with their own data grid with different columns.  What I'm seeing is that when the first tab is created, the grid has all the correct columns.  When I create a new second tab, the columns are the same as the first tab's.  It's like they are linked somehow.  Also the FieldLayoutInitialized handler is not called on the second tab's grid creation.  What am I doing wrong?