我正在使用机制通过手势移动Stacklayout。是否有另一个事件检测到StackLayout的Y位置变化?这意味着我想在StackLayout位置被向上或向下平移时捕获。
<StackLayout x:Name="bottomDrawer" BackgroundColor="Olive" AbsoluteLayout.LayoutBounds="0.5,1.00,0.9,0.04" AbsoluteLayout.LayoutFlags="All">
<StackLayout.GestureRecognizers>
<PanGestureRecognizer PanUpdated="PanGestureHandler" />
</StackLayout.GestureRecognizers>
</StackLayout>
答案 0 :(得分:1)
PropertyChanging
上有PropertyChanged
和BindableObject
个事件(StackLayout
层次结构中的一个类)。
因此,您可以绑定Y
,Height
和/或LayoutBounds
属性上的更改。
使用事件的示例:
aStackLayoutObject.PropertyChanging += (sender, e) =>
{
switch (e.PropertyName)
{
case "Y":
Log.WriteLine($"{e.PropertyName} : {(sender as StackLayout).Y}");
break;
case "Height":
Log.WriteLine($"{e.PropertyName} : {(sender as StackLayout).Height}");
break;
case "LayoutBounds":
Log.WriteLine($"{e.PropertyName}";
break;
};
aStackLayoutObject.PropertyChanged += (sender, e) =>
{
switch (e.PropertyName)
{
case "Y":
Log.WriteLine($"{e.PropertyName} : {(sender as StackLayout).Y}");
break;
case "Height":
Log.WriteLine($"{e.PropertyName} : {(sender as StackLayout).Height}");
break;
case "LayoutBounds":
Log.WriteLine($"{e.PropertyName}";
break;
};