2012-02-09 52 views
0

在編碼我用一個ListView和定義的模板,在該級別的資源的WPF應用程序的本地資源:衝突窗口和WPF應用

<ListView IsSynchronizedWithCurrentItem="true" ItemTemplate="{StaticResource CardViewTemplate}"> 
    <!--ItemTemplate="{StaticResource CardViewTemplate}" --> 
    <ListView.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel></WrapPanel> 
     </ItemsPanelTemplate> 
    </ListView.ItemsPanel> 
    <ListView.Resources> 
     <DataTemplate x:Key="CardViewTemplate"> 
      <GroupBox Header="{Binding Path=Product Name}" Width="290" BorderThickness="4" FontSize="14" 
        FontStyle="Normal" Padding="10" BorderBrush="DarkBlue" Background="{x:Null}" Margin="12" 
        UseLayoutRounding="True"> 
       <StackPanel Name="stackPanel1"> 
        <WrapPanel Orientation="Vertical" Name="wrapPanel1"> 
         <WrapPanel Orientation="Horizontal"> 
          <TextBlock MinWidth="80" Text="{Binding Path=Product 
                  Name}" FontSize="16" FontWeight="Bold" 
            TextAlignment="Center" /> 
         </WrapPanel> 
      </GroupBox> 
     </DataTemplate> 
    </ListView.Resources> 
</ListView> 

這工作完全然而,當我使用的資源(表達黑暗)在窗口級別ListView顯示爲空白。

任何建議,可能是什麼原因?我已經嘗試了所有我能想到

+0

你是什麼意思與「[...]當我在窗位[...]使用資源(表達式暗)」?你有沒有嘗試使用另一個主題?或者你的意思是表達混合與它的黑暗主題? – DHN 2012-02-09 06:11:24

回答

0

可能有多個reasosns ...

  1. 是您ListView直屬您Window
  2. 如果您Dark模板配置是否正確?
  3. 是否適用,如果你直接設置它的列表視圖(不帶靜電資源引用)下...

    <ListView> 
        <ListView.ItemTemplate> 
         <DataTemplate x:Key="CardViewTemplate"> 
          ... 
         </DataTemplate> 
        </ListView.ItemTemplate> 
    </ListView> 
    

+0

感謝您的回覆。試着直接應用它,通過在列表視圖中設置它,但沒有改變。所以我在模板中註釋掉了ListView樣式,它顯示出來了。所以它的模板,只是不確定哪個屬性。 – dsgrant07 2012-02-09 15:40:35

0

,當我在窗口級別使用資源(表達式暗)

主題不正確地在窗口級別上工作。或者你究竟做了什麼

+0

我實際上在窗口級應用了主題。什麼是更好的方式來應用這個? – dsgrant07 2012-02-09 15:38:09

+0

@ dsgrant07:'Application.Resources' – 2012-02-09 18:14:24

+0

謝謝您的建議。當我在應用程序級別應用它時,最初的問題會再次出現。儘管主題沒有爲列表視圖定義樣式,並且該樣式直接應用於該列表視圖,但是該列表視圖是空白的。有什麼建議麼? – dsgrant07 2012-02-09 21:41:17

0

有一個(幾個)問題與ExpressionDark。模板。

對於空行的問題,修改主題以下行後:

<GridViewRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,2,0,2" VerticalAlignment="Stretch" /> 

通過後加一個ContentPresenter:

<GridViewRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,2,0,2" VerticalAlignment="Stretch" /> 
    <ContentPresenter /> 

我有同樣的問題,在這裏找到了解決辦法: http://bogdanvarlamov.com/2011/01/21/expressiondark-wpf-theme-listview-problem/

我越用ExpressionDark了更多的問題,我用它查找和我就越想動以更好的主題!