XAML Maui C#中的Get Child

q9yhzks0  于 2023-08-01  发布在  C#
关注(0)|答案(1)|浏览(104)

我想得到一个孩子在净毛伊C#。
代码看起来像这样:
XAML:

<Border>
   <Border.GestureRecognizers>
      <TapGestureRecognizer 
         Command="{Binding FollowClickedCommand}" 
         CommandParameter="."/>
   </Border.GestureRecognizers>
          <Label Text="Follow" Margin="10,0"/>
</Border>

字符串
C#:

[RelayCommand]
        async void FollowClicked(Border callerObject)
        {
            
        }


我想做的事情是在C#中获取一个调用者子级,在本例中是一个Label。

dffbzjpn

dffbzjpn1#

(Label)callerObject.Content.GetVisualTreeDescendants().Where(x=> x.GetType() == typeof(Label)).First();

字符串

相关问题