c# - 如何在没有 SetLeft 的情况下以编程方式更改图像位置?
问题描述
我以前搜索过,我认为Canvas.SetLeft(image, double)
这将是答案,但它没有做任何事情
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"C:\Users\alu\Desktop\caballos_jpg\serie_2\02.jpg", UriKind.RelativeOrAbsolute);
myBitmapImage.EndInit();
imgCb01.Source = myBitmapImage;
Canvas.SetLeft(imgCb01, 152d);//This aint working
Canvas.SetTop(imgCb01, 285.0);//This aint working
Thickness margin = imgCb01.Margin;//I thought this lines would move my image
margin.Left = (imgCb01.Margin.Left) + 5;//slightly to the right
imgCb01.Margin = margin;//and they do but they are hiding (TT-TT) ...
所以我有这段代码,既不工作SetLeft
也不SetTop
工作,我想我可以做修改边距的技巧,但随后图像“向前”移动,而图像控件保持其位置,因此看起来图像刚刚变得不可见。
解决方案
好吧,我认为这只是来自 Microsoft Visual Studio 的一些奇怪的随机错误,我刚刚在其他 PC 上重新开始复制 XAML,它工作得很好......抱歉打扰你了 :')
推荐阅读
- netsuite - 卡在将商品图片添加到销售订单中
- python-3.x - 向函数创建的 Pandas DataFrame 添加列?
- python - 如何解决 AttributeError:'list' 对象没有属性 'shape'?
- r - 如何按R中的列值范围过滤行?
- reactjs - 多个用户的表格内的雷达图 React
- json - 如何使用方向 api 在 excel 中获取距离(在 VBA 中使用 JSON)
- android - 活动回栈 FLAG_ACTIVITY_NEW_TASK
- vue.js - 如何使用 vue spa 应用程序删除 url 中的查询字符串?
- graph - 在 Tiger Graph 中检索所有节点和关系的 GSQL 过程是什么?
- java - 在性能方面,在 Java 中执行一个 for 多个操作或多个 fors 一个操作对 Java 有什么影响?