<Style x:Key="OrderGroupTemplateStyle" TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Name.ShowDetailedInfo, UpdateSourceTrigger=PropertyChanged}" Value="False">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="3" Margin="2">
<StackPanel Background="LightGoldenrodYellow">
<ContentControl Content="{Binding Path=.}" Style="{StaticResource MyRecordViewModelShortStyle}"/>
<ListView ItemsSource="{Binding Path=Items}" Margin="4">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="Padding" Value="2"/>
<EventSetter Event="MouseDoubleClick" Handler="ItemsControl_SelectionChanged"/>
</Style>
</ListView.ItemContainerStyle>
我想在listview選擇更改時做一些工作。因爲我正在使用樣式,所以我無法在ListView上使用SelectionChanged事件。我試圖用EventSetter但在編譯項目中的任何錯誤:不能指定在一個樣式一個目標標籤 風格內的WPF ListView SelectionChanged不起作用。 EventSetter
事件「MouseDoubleClick」。 改爲使用EventSetter。
有人能幫我嗎?
其實我不能。當我嘗試使用它時出現以下錯誤:錯誤無法在樣式中的Target標籤上指定事件'SelectionChanged'。改用EventSetter。 – 2010-06-29 10:47:18
嘗試此 <形式X:鍵= 「OrderGroupTemplateStyle」 的TargetType = 「{x:類型ContentControl中}」> 。 .. –
Ragunathan
2010-06-30 05:00:27