2
我在选项卡上的画布内部有一个网格。 该网格包含一个大的位图图像, 我已经(试图)将网格的大小限制为该选项卡的大小,并且在网格周围还有一个5像素的边距。WPF数据绑定问题
imageTab.cs
public ImageTab(SendInfo sendInfo, int numImge, int numAccs)
{
imageDisplay = new ImageDisplay(sendInfo, numImge, numAccs);
imageDisplay.ClipToBounds = true;
CreateCanvas();
}
private void CreateCanvas()
{
Canvas canvas = new Canvas();
canvas.Children.Add(imageDisplay);
this.AddChild(canvas);
}
ImageDisplay.xaml
<UserControl x:Class="MyProj.ImageDisplay">
<Grid Margin="5,5,5,5" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl, AncestorLevel=1}, Path=ActualHeight}">
<Image/>
</Grid>
</UserControl>
网格脱落略微使图像的底部的标签区域的底部被切除。 我的数据绑定有问题,我是否需要应用某种偏移量? (选项卡的大小 - 边距是10像素?)
如果你想要网格填充选项卡,那么你为什么把它放在一个画布?画布适用于需要以精确尺寸(X,Y)坐标精确定位控件的情况 - 对于“填充父项”等动态布局来说,这没有好处。 – 2011-05-10 18:10:24