ビットマップを含むWPF(.NET 3.5)ツリービューがあります。特別 何も:ビットマップのTreeView/ScrollViewレンダリングのバグ?
<ControlTemplate x:Key="ctrlOutputTree" TargetType="{x:Type vo:OutputTreeView}">
<TreeView x:Name="OutputTree" ItemContainerStyle="{DynamicResource TreeViewItemStyle}"
KeyboardNavigation.TabNavigation="Cycle" SnapsToDevicePixels="True" MouseDown="OutputTree_MouseDown"
Loaded="OutputTree_Loaded" RenderOptions.BitmapScalingMode="NearestNeighbor">
<TreeView.Resources>
<Style TargetType="TreeViewItem">
<EventSetter Event="RequestBringIntoView" Handler="OutputTree_RequestBringIntoView"/>
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
</Style>
</TreeView.Resources>
<TreeViewItem ItemsSource="{Binding Converter={StaticResource featureDiffsSourceCreator},Mode=OneWay}"
IsExpanded="True" Margin="0,4,0,0"
KeyDown="AttrDiffTreeviewItem_KeyDown">
</TreeViewItem>
</TreeView>
</ControlTemplate>
TreeViewItems:
<ControlTemplate x:Key="ImageTemplate">
<Image VerticalAlignment="Top" Margin="3,1,0,0"
RenderOptions.BitmapScalingMode="NearestNeighbor"
RenderOptions.EdgeMode="Aliased"
Stretch="None">
<Image.Source>
<!-- <BitmapImage UriSource="c:\\imageBMP_test.bmp" />-->
<MultiBinding Converter="{StaticResource imageConverter}">
<Binding Path=....
</MultiBinding>
</Image.Source>
</v:Image>
</ControlTemplate>
ビットマップが(ネイティブコントロールから)imageConverter中たBitmapSourceとして生成されます。
System::Drawing::Bitmap^ b = System::Drawing::Image::FromHbitmap((IntPtr)aBmp);
IntPtr hb = b->GetHbitmap();
System::Windows::Media::Imaging::BitmapSource^ bs =
System::Windows::Interop::Imaging::CreateBitmapSourceFromHBitmap(hb,
System::IntPtr::Zero,
Int32Rect(0,0,nWidth,nHeight),
BitmapSizeOptions::FromEmptyOptions());
すべて表示されますが、ツリーをスクロールするとビットマップが歪んで表示されることがあります。ほとんどが底に近い。ツリーのサイズを変更する必要が生じることもありますが、遅かれ早かれ発生します。
ItemXはテキストで、隣にあるテーブルはビットマップです。
これが間違っていると、スクロールバーの位置 - 親指でツリーをスクロールすると1ピクセル上下になり、シャープになり、再び良好になります。 しかし、私はアップ/ダウンスクロールバー上の矢印でスクロールした場合、ビットマップは、いくつかのクリックには無効のまま(そして消える)
私はXAML MultiBinding/imageConverter
にしたBitmapSourceの生成を交換した場合 - ><BitmapImage UriSource="c:\\imageBMP_test.bmp"
、これは発生しません。問題。
System::Drawing::Bitmap^ b = gcnew System::Drawing::Bitmap("c:\\imageBMP24_96dpi_small.bmp");
IntPtr hb = b->GetHbitmap();
System::Windows::Media::Imaging::BitmapSource^ bs =
System::Windows::Interop::Imaging::CreateBitmapSourceFromHBitmap(hb,
System::IntPtr::Zero,
Int32Rect(0,0,nWidth,nHeight),
BitmapSizeOptions::FromEmptyOptions());
:私は、ファイル(96DPIで24または32ビットBMP)からの読み取りにしたBitmapSourceの生成を変更する場合は
(私は、& 96DPI 24ビットにimageBMP_test.bmpを世話をするためにそれ以外にもよくありませんがあります)
すべてのヘルプ、アイデアがいただければ幸いです。
その後いくつかのスクロールの後、私はこれを得ました。
私が試したこと:
チェックされて生成された 'BitmapSource'は96 DPIです。
ファイルに保存されたすべての 'BitmapSource' - 画面上で歪んでいる間はすべて問題ありませんでした。
私はアイデアがありません、それはWPFのバグのようですか?または、ビデオドライバですか? (NVIDIAのQuadro /ラップトップ/ win7の64bit版)
はSO SHORT IN
TreeViewコントロールは、ビットマップがXAMLで指定したファイルからロードされ表示されます。OK(時々、ここで非常に小さなグリッチが、それらは許容される)
ビットマップソースからのビットマップを表示します。時にはFAILS(スクロール中)
ちょうど楽しみのために 'ViewBox'を使ってみてください。 – AnjumSKhan
@AnjumSKhan詳細を教えてください。どこで使うべきですか? – Zotyi
Btw、元の質問をmore info/example/screenshot – Zotyi