【问题标题】:WPF absolute positioning in InkCanvasInkCanvas 中的 WPF 绝对定位
【发布时间】:2009-09-10 04:04:20
【问题描述】:

我正在尝试在InkCanvas 中定位一个矩形。我正在使用以下方法。不幸的是,当我添加矩形时,它会显示在(0,0)。虽然当我查询左侧属性是否为0 时,我得到一个非零值。有谁知道这可能是为什么?

干杯,

尼禄

InkCanvas _parent = new InkCanvas();
private void AddDisplayRect(Color annoColour, Rect bounds)
    {
        Rectangle displayRect = new Rectangle();
        Canvas.SetTop(displayRect, bounds.Y);
        Canvas.SetLeft(displayRect, bounds.X);

        // check to see if the property is set
        Trace.WriteLine(Canvas.GetLeft(displayRect));
        displayRect.Width = bounds.Width;
        displayRect.Height = bounds.Height;
        displayRect.Stroke = new SolidColorBrush(annoColour);
        displayRect.StrokeThickness = 1;

        _parent.Children.Add(displayRect);            
    }

【问题讨论】:

    标签: wpf css-position inkcanvas


    【解决方案1】:

    终于搞清楚了。我也觉得有点傻而不是Canvas.SetTop()需要使用InkCanvas.SetTop

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多