首页 > 解决方案 > 如何在选择图像以及保存时使用标签动态获取x和y值而不是硬编码,同时在该位置显示数字

问题描述

我有两个要求

1.我只使用customimagerenderer参考链接获得了x和y坐标:https ://social.msdn.microsoft.com/Forums/en-US/50318e68-4e06-4d08-8d2d-d839f720d006/how-do-i -put-points-on-image-and-get-coordinates-of-those-points-?forum=xamarinforms

2.第二个选择特定位置的图像我添加了数字,例如:1,2,3 如果有任何可能的解决方案来实现请发送,我不知道如何实现这一点。谢谢提前

<AbsoluteLayout>
                <StackLayout>
                  <Image Source="mypic.jpg" x:Name="pic"/>
                    </StackLayout>
                <Label Text="1" x:Name="firstlabel"
                       BackgroundColor="Transparent"
                       TextColor="Red"
                       AbsoluteLayout.LayoutFlags="PositionProportional"
                       AbsoluteLayout.LayoutBounds=".1,.1,10,10"
                       />
                    <Label Text="2" x:Name="secondlabel"
                       BackgroundColor="Transparent"
                       TextColor="Red"
                       AbsoluteLayout.LayoutFlags="PositionProportional"
                       AbsoluteLayout.LayoutBounds=".1,.2,10,20"
                       >
                        <Label.GestureRecognizers>
                            <TapGestureRecognizer Tapped="on_Tapped"/>
                        </Label.GestureRecognizers>
                    </Label>
                      <Label Text="3" x:Name="thirdlabel"
                       BackgroundColor="Transparent"
                       TextColor="Red"
                       AbsoluteLayout.LayoutFlags="PositionProportional"
                       AbsoluteLayout.LayoutBounds=".8,.1,10,20"
                       />
            </AbsoluteLayout>

也尝试上面的代码,但 AbsoluteLayout.LayoutBounds 设置硬编码也他们设置了多个标签

标签: xamarin.formslabelcoordinatesabsolutelayout

解决方案


推荐阅读