简体   繁体   中英

Windows 10 mobile (UWP) Flyout with calendar picker locking on screen

I've created flyout to my appbarbutton with one textbox an control to pick a date 'CalendarDatePicker'.

The problem is that when I choose a date from control calendar is shown and my flyout dissapear. I thought about locking my Flyout, but I don't know how do to it. It dissapear even when I click outside of flyout. Is it possible?

<AppBarButton x:Name="btnAppAddEvent" Icon="Add" Label="Dodaj"  >
            <AppBarButton.Flyout>
                <Flyout x:Name="flAdd" Placement="Full" >
                    <Flyout.FlyoutPresenterStyle>
                        <Style TargetType="FlyoutPresenter">
                            <Setter Property="MaxHeight" Value="350"></Setter>
                            <Setter Property="MaxWidth" Value="300"></Setter>
                            <Setter Property="Background" Value="#FF8096BD"></Setter>
                        </Style>
                    </Flyout.FlyoutPresenterStyle>

                    <StackPanel Height="300"  >
                        <TextBox x:Name="txtNameAdd"  FontSize="23"  Height="40"></TextBox>

                        <CalendarDatePicker HorizontalAlignment="Center"  x:Name="calendar" Margin="0,30,0,0" />
                        <AppBarButton x:Name="btnAddEv" BorderBrush="Black" HorizontalAlignment="Center"  Icon="Accept" Click="btnAddEv_Click"  Margin="0,20,0,0"></AppBarButton>
                        <TextBlock x:Name="txtMess2" HorizontalAlignment="Center"  FontSize="15" Foreground="Red" Margin="0,10,0,0"  ></TextBlock>

                    </StackPanel>
                </Flyout>
            </AppBarButton.Flyout>
        </AppBarButton>

The problem is that when I choose a date from control calendar is shown and my flyout dissapear.

I tested your code on my side. In the newest windows 10 SDK build 14393 this issue is no longer existed. When we choose a data from calendar control which is inside the Flyout control, the Flyout will not disappear. But in previous SDK like build 10586 your issue is existed and it seems like currently we cannot change it by setting.

It dissapear even when I click outside of flyout.

For this scenario it is by design. According to the description of Flyout control:

Represents a control that displays lightweight UI that is either information, or requires user interaction. Unlike a dialog, a Flyout can be light dismissed by clicking or tapping outside of it, pressing the device's back button, or pressing the 'Esc' key.

Flyout control is designed for displaying lightweight UI and can be light dismissed. If you don't want the UI dismissed by tapping outside you can try other fly out controls like ContentDialog control. For more details about ContentDialog please reference the official sample .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM