У меня есть кнопка в заголовке HeaderedContentControl. Когда я нажимаю на кнопку, команда запускается правильно, но поскольку фактический элемент списка не выбран, у меня нет данных для работы.Как заставить HeaderedContentControl быть выбранным, когда дочерний элемент управления выбран или взаимодействует с первым?
Вот мой элемент управления
<ListBox x:Name="SearchList"
Grid.Row="1"
Grid.Column="0"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Path=SearchResults}"
SelectedItem="{Binding Path=SelectedResult,Mode=TwoWay,Converter={StaticResource DebugConverter}}"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
ScrollViewer.VerticalScrollBarVisibility="Visible" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border Width="600"
Margin="20,2,0,0"
Style="{StaticResource BorderStyle}">
<sb:BindingHelper.Binding>
<sb:BindingList>
<sb:RelativeSourceBinding TargetProperty="Background"
RelativeMode="FindAncestor"
AncestorType="ListBoxItem"
Converter="{StaticResource DebugConverter}"
ConverterParameter="AlternatingRows" />
</sb:BindingList>
</sb:BindingHelper.Binding>
<toolkit:HeaderedContentControl IsTabStop="True">
<toolkit:HeaderedContentControl.Header>
<Grid Width="575"
Margin="5,5,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0"
Grid.Row="0"
Text="{Binding Path=PatientName}"
HorizontalAlignment="Left"
Margin="0" />
<Button Grid.Column="3"
Grid.Row="0"
Content="Complete Survey"
IsTabStop="False">
<sb:BindingHelper.Binding>
<sb:BindingList>
<sb:RelativeSourceBinding Path="DataContext.OpenSurveyCommand"
TargetProperty="Command"
RelativeMode="FindAncestor"
AncestorType="ListBox"
Converter="{StaticResource DebugConverter}"
ConverterParameter="SurveyCommandButton" />
<sb:RelativeSourceBinding Path="DataContext.HasFocus"
TargetProperty="Focus" />
</sb:BindingList>
</sb:BindingHelper.Binding>
</Button>
</Grid>
</toolkit:HeaderedContentControl.Header>
<sb:BindingHelper.Binding>
<sb:RelativeSourceBinding TargetProperty="IsExpanded"
Path="IsSelected"
RelativeMode="FindAncestor"
AncestorType="ListBoxItem"
BindingMode="TwoWay" />
</sb:BindingHelper.Binding>
<Grid Margin="5,2,0,2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="275" />
<ColumnDefinition Width="250" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="{Binding MRN,Converter={StaticResource StringLabelConverter},ConverterParameter=MRN}" />
<TextBlock Grid.Row="1"
Grid.Column="0"
Style="{StaticResource SearchResultsTextBlockStyle }"
Text="{Binding OriginalVisitNumber,Converter={StaticResource StringLabelConverter},ConverterParameter='Original Visit Number'}" />
<TextBlock Grid.Row="2"
Grid.Column="0"
Style="{StaticResource SearchResultsTextBlockStyle }"
Text="{Binding OriginalAdmitDate,Converter={StaticResource StringLabelConverter},ConverterParameter='Original Admit Date'}" />
<TextBlock Grid.Row="3"
Grid.Column="0"
Style="{StaticResource SearchResultsTextBlockStyle }"
Text="{Binding OriginalReason,Converter={StaticResource StringLabelConverter},ConverterParameter='Original Reason'}" />
<TextBlock Grid.Row="1"
Grid.Column="1"
Style="{StaticResource SearchResultsTextBlockStyle }"
Text="{Binding ReAdmitVisitNumber,Converter={StaticResource StringLabelConverter},ConverterParameter='ReAdmit Visit Number'}" />
<TextBlock Grid.Row="2"
Grid.Column="1"
Style="{StaticResource SearchResultsTextBlockStyle }"
Text="{Binding ReAdmitDate,Converter={StaticResource StringLabelConverter},ConverterParameter='Readmit Date'}" />
<TextBlock Grid.Row="3"
Grid.Column="1"
Style="{StaticResource SearchResultsTextBlockStyle }"
Text="{Binding ReAdmitReason,Converter={StaticResource StringLabelConverter},ConverterParameter='ReAdmit Reason'}" />
</Grid>
</toolkit:HeaderedContentControl>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>