1
我在WPF項目中使用ScrollViewer
,我正在努力處理它的內容。 這個SV包含在這個窗口中有很多其他UI項目,我想讓ScrollViewer
滾動的圖像在SV區域內不可見,或者至少在其他元素之後。如何隱藏ScrollViewer之外的內容?
這是我的代碼位的SV(是的,這是一個網格內):
<Grid Name="mainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200*" />
<ColumnDefinition Width="802*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30*" />
<RowDefinition Height="500*" />
<RowDefinition Height="199*" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1" Grid.ColumnSpan="2" Name="map" Margin="0,0,0,0" PanningMode="Both" HorizontalScrollBarVisibility="Visible" Background="DarkGray" ClipToBounds="True">
<WindowsFormsHost Name="windowsFormsHost1" Cursor="Cross" HorizontalAlignment="Left" VerticalAlignment="Top" ClipToBounds="True" />
</ScrollViewer>
</grid>
我有另外一個問題,我想,而對是我的鼠標滾動圖像。 原樣,它只在鼠標位於ScrollViewer
的空白區域時纔會滾動。
這是後面的部分代碼:
public MainWindow()
{
InitializeComponent();
//Creation of the map
Map newMap = new Map();
newMap.setMapStrategy(new SmallMapStrategy());
newMap.createMap();
//Put the map in the PB as an image
System.Windows.Forms.PictureBox pictureBox = new System.Windows.Forms.PictureBox();
pictureBox.Width = newMap.grid.Count * 2; pictureBox.Height = newMap.grid.Count * 2;
newMap.afficher(pictureBox);
windowsFormsHost1.Width = newMap.grid.Count * 2; windowsFormsHost1.Height = newMap.grid.Count * 2;
windowsFormsHost1.Child = pictureBox;
}
我很難想象這一點 - 屏幕截圖可能有所幫助。此外,發佈您的網格的其餘部分(或者至少更多)。 –
爲了解決可見性問題,您是否嘗試將ScrollViewer的ClipToBounds屬性設置爲true? – Backlash
ClipToBounds無效:/ –