2

よくわからない動作について、小さなテストケースを書きました。誰かが私のためにこれを解決できるなら、私は最も興味があります.

私はApp.xamlに、

<Application x:Class="WpfApplication1.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="MainWindow.xaml">
  <Application.Resources>
    <Style TargetType="Border">
      <Setter Property="BorderBrush"
          Value="Crimson" />
    </Style>
  </Application.Resources>
</Application>

次のウィンドウのスタイルを削除したいので、次のようにスタイルを再定義します。

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">

  <ListView>
    <ListView.Resources>
      <Style TargetType="Border" />
     </ListView.Resources>
     <ListView.View>
       <GridView>
         <GridViewColumn Header="test1" />
         <GridViewColumn Header="test2" />
       </GridView>
     </ListView.View>
  </ListView>
</Window>

上記のようにスタイルを再定義すると、アプリケーション リソースに記述した内容が上書きされるという印象を受けました。これは必須ではありませんが、ボーダーブラシを無効に設定してテストしました。

以下は、ボーダー スタイルがないと想定したウィンドウのスクリーン キャプチャです。

テスト ケース ウィンドウ

デザイナーでは問題ないように見えますが、実行時にはそうではありません。さらに、これは境界線を除く他のターゲット タイプでも機能します (TextBlock および他のいくつかのコントロールでテスト済み)。

4

1 に答える 1

0

ListView リソースで宣言したスタイルで、BorderBrush のセッターを追加しようとしましたか?

于 2013-03-20T16:00:10.163 に答える