I have an expander containing a datagrid with a rowdetailstemplate.
When I click on a datagrid row to see the row details template, the expander closes!
Anyone know why and how to fix this?
Update
Turns out that something else is happening:
The expanders are all contained in a TabItem. When I click on the grid row, TabControls.SelectionChanged fires (WHY!!!?!?!!?!?!?!) and then the data is recalculated and rebound.
So the real question is why does click a DataGrid row cause the Parent TabControl's SelectionChanged Event to fire? Here's the XAML:
<Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="BPPDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPPDemo"
Title="BPP Demo" Height="600" Width="700" Loaded="Window_Loaded">
<Window.Resources>
<local:AddrStatusColorConverter x:Key="addressStatusColorConverter"/>
<local:BoolToVisConverter x:Key="boolToVisConverter"/>
</Window.Resources>
<DockPanel>
<Menu DockPanel.Dock="Top">
<Menu.Items>
<MenuItem Header="File">
<MenuItem Header="Open Assessment" Command="{Binding SelectAssessmentCommand}"></MenuItem>
<MenuItem Header="Import Properties" Command="{Binding ImportPropertiesCommand}"></MenuItem>
</MenuItem>
<MenuItem Header="Properties" Visibility="{Binding IsSelected, ElementName=tabProperties,Converter={StaticResource boolToVisConverter}}">
<MenuItem Header="Delete All Properties" Command="{Binding DeleteAllPropertiesCommand}"></MenuItem>
<MenuItem Header="Resolve Invalid Addresses" Command="{Binding ValidateAddressesCommand}"></MenuItem>
<MenuItem Header="Select Situs" Command="{Binding SelectSitusCommand}"/>
</MenuItem>
</Menu.Items>
</Menu>
<DockPanel Margin="10">
<TextBlock Text="{Binding Assessment.Name}" FontWeight="Normal" FontSize="24" Foreground="#FF5C9EB7" DockPanel.Dock="Top" Margin="0,0,0,10"/>
<TabControl SelectionChanged="TabControl_SelectionChanged">
<TabItem x:Name="tabProperties" Header="Properties">
<DataGrid ItemsSource="{Binding Properties}" AutoGenerateColumns="False" IsReadOnly="True" SelectedItem="{Binding SelectedProperty,Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
<DataGridTextColumn Header="Cost" Binding="{Binding Cost,StringFormat='{}{0:c}'}"/>
<DataGridTextColumn Header="Year Acquired" Binding="{Binding YearAcquired}"/>
<DataGridTextColumn Header="Life In Years" Binding="{Binding LifeInYears}"/>
<DataGridTextColumn Header="Schedule" Binding="{Binding Schedule}"/>
<DataGridTextColumn Header="Current Value" Binding="{Binding CurrentValue,StringFormat='{}{0:c}'}" />
<DataGridTextColumn Header="Tax" Binding="{Binding Tax,StringFormat='{}{0:c}'}" />
<DataGridTemplateColumn Header="Address">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Address}" Foreground="{Binding AddressStatus, Converter={StaticResource addressStatusColorConverter}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Address Status" Binding="{Binding AddressStatus}"/>
<DataGridTextColumn Header="Situs" Binding="{Binding Situs}"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<TextBlock>THIS ONE WORKS! WHY DOESN'T THE OTHER ONE????</TextBlock>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</TabItem>
<TabItem Header="Listings" Name="tabListings">
<DataGrid x:Name="SitusGroups" AutoGenerateColumns="false" SelectionMode="Single" SelectionUnit="FullRow">
<DataGrid.Columns>
<DataGridTextColumn Header="Situs" Binding="{Binding Situs,StringFormat='{}{0:c}',TargetNullValue='none'}"></DataGridTextColumn>
<DataGridTextColumn Header="Cost" Binding="{Binding Cost,StringFormat='{}{0:c}'}"></DataGridTextColumn>
<DataGridTextColumn Header="Value" Binding="{Binding Value,StringFormat='{}{0:c}'}"></DataGridTextColumn>
<DataGridTextColumn Header="Tax" Binding="{Binding Tax,StringFormat='{}{0:c}'}"></DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<TextBlock>I JUST WANT TO SEE THIS WHEN I CLICK ON A ROW!</TextBlock>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</TabItem>
</TabControl>
</DockPanel>
</DockPanel>