我需要一个Control
300000000Width
和的 WPF Height
,我将Rectangles
根据一些输入在其上绘制。我正在绘制Rectangle
控件OnRender
的。出于测试目的,我将控件放在 a 中ScrollViewer
,并绘制Rectangles
从 (0,0) 到 (1000,1000) 的每个像素。如果Width
&Height
是 1000000,Rectangles
则正确绘制,如下所示,(Rectangles
绘制在从 (0,0) 到 (1000,1000) 的所有像素上,因此看起来像下面链接中的 on)
https://social.msdn.microsoft.com/Forums/getfile/950012
但是,如果我将大小增加到 3000000,则图中缺少几行,如下所示, https://social.msdn.microsoft.com/Forums/getfile/950018
我的 Xaml:
<ScrollViewer x:Name="MainScrollViewer"
Grid.Row="2"
Grid.ColumnSpan="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<waferControl:WaferMapControl x:Name="WaferControl"
Grid.Row="2"
Grid.ColumnSpan="2"
Width="30000000"
Height="30000000"
Margin="10"
ColumnCount="{Binding WaferInfo.ColumnCount}"
RowCount="{Binding WaferInfo.RowCount}"
SelectedCells="{Binding SelectedCellCollection}"
Visibility="Collapsed" />
</ScrollViewer>
我正在使用以下代码OnRender
。WaferMapControl
private void RenderBackgroud(IEnumerable lists`enter code here`)
{
using (DrawingContext dc = _backgroundDv.RenderOpen())
{
SolidColorBrush brush = Brushes.Black;
if (brush.CanFreeze)
brush.Freeze();
foreach (GridCellInfo cellInfo in lists)
{
double length = cellInfo.GridRange;
var point = new Point(
cellInfo.RowIndex + 1,
ActualHeight - cellInfo.ColumnIndex - length);
RenderBackgroud(dc, point, brush, length);
}
}
}
private void RenderBackgroud(DrawingContext dc, Point point, Brush brush, double length)
{
var rect = new Rect(point, new Size(length, length));
dc.DrawRectangle(brush, null, rect);
}
包含 x , cellInfo
y 坐标。点计算是从左下角开始绘制的。在我的示例中长度为 1。
谁能帮帮我,这里有什么问题。如果你需要我这边的任何东西,请告诉我。