Xamarin 양식-한 페이지에 여러보기 [닫힘]

Dec 09 2020

그래서 나는 페이지 에서 다중보기 를 달성해야합니다. 이와 같은 것이지만 가능한 교차 플랫폼을 만드는 방법을 찾을 수 없습니다. IOS에서 페이지에 여러 뷰 컨트롤러를 추가하여이를 달성 할 수 있음을 알 수 있지만 xamarin 양식에서이 작업을 수행 할 수 있습니까?

이에 대한 경험이 있으면 알려주십시오.

미리 감사드립니다!

답변

LucasZhang-MSFT Dec 09 2020 at 18:21

이를 구현할 수있는 많은 솔루션이 있습니다. 예를 들어 AbsoluteLayout 을 사용하여 스 와이프보기를 만들 수 있습니다.

ContentPage에서

<AbsoluteLayout BackgroundColor="White" AbsoluteLayout.LayoutBounds="0,1,1,1">
        <!--  -->

        <Button Clicked="Button_Clicked" Text="Test"  AbsoluteLayout.LayoutBounds="0.5,0.3,0.2,0.05" AbsoluteLayout.LayoutFlags="All" />

        <StackLayout x:Name="bottomBar" BackgroundColor="Olive" AbsoluteLayout.LayoutBounds="0.5,1.0,1.0,0.04" AbsoluteLayout.LayoutFlags="All">
            

            <!-- put the content of swipe here -->

        </StackLayout>
    </AbsoluteLayout>

코드 뒤에

    bool isShow;
    const double layoutPropHeightMax = 0.45;
    const double layoutPropHeightMin = 0.06;
   //you could set the height here as you want

    private void Button_Clicked(object sender, EventArgs e)
    {
        if(!isShow)
        {
            //show the keyboard

            Device.BeginInvokeOnMainThread(async () =>
            {

                var height = layoutPropHeightMin;

                while (height < layoutPropHeightMax)
                {
                    await Task.Delay(1);
                    height += 0.04;

                    AbsoluteLayout.SetLayoutBounds(bottomBar, new Rectangle(0.5, 1.0,1.0, height));
                }

            });

        }

        else
        {
            // hide the keyboard
            Device.BeginInvokeOnMainThread(async () =>
            {

                var height = layoutPropHeightMax;

                while (height > layoutPropHeightMin)
                {
                    await Task.Delay(1);
                    height -= 0.04;

                    AbsoluteLayout.SetLayoutBounds(bottomBar, new Rectangle(0.5, 1.0, 1.0, height));
                }

            });

        }


        isShow = !isShow;
    }

다음은 추천 할 수 있는 유사한 문제 입니다.