2012-05-07 43 views
5

Tôi đang sử dụng MahApps.Metro để đạt được giao diện người dùng Metro trong ứng dụng của mình.Ghi đè kiểu trong WPF

Tôi có một listview và MahApps.Metro đang thay đổi phong cách cho nó. Phong cách của MahApps cho chế độ xem danh sách là here.

tải các phong cách:

<Window.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/FineRSS;component/Resources/Icons.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Window.Resources> 

tôi cần phải theo dõi các listviewitems chọn vì vậy tôi sử dụng phương pháp tiếp theo:

<ListView.ItemContainerStyle> 
       <Style TargetType="{x:Type ListViewItem}"> 
        <Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/> 
       </Style> 
</ListView.ItemContainerStyle> 

Nhưng phong cách MahApps.Metro là ghi đè mặc định ListView của.

Tôi có thể làm gì để giữ cho một trong hai kiểu và Gắn buộc được chọn?

Trả lời

10

Tôi không tích cực Tôi làm theo những gì bạn đang cố gắng làm, nhưng nó sẽ có ý nghĩa để làm cho Style của bạn là BasedOn hình mặc định được tải?

Something như

<ListView.ItemContainerStyle> 
    <Style TargetType="{x:Type ListViewItem}" 
      BasedOn="{StaticResource {x:Type ListViewItem}}"> 
     <Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/> 
    </Style> 
</ListView.ItemContainerStyle> 
+0

mặc dù VS không thích dòng Basedon = "{StaticResource {x: Loại ListViewItem}}" có vẻ như được làm việc. cảm ơn bạn. – ieaglle

+0

Cùng một câu hỏi tôi có. Vẫn đang quen với việc làm việc với XAML. – cubski

Các vấn đề liên quan