private async void ControlButtonPanelClicked(object sender, ItemClickEventArgs e)
        {
            var clickedItem = e.ClickedItem as ControlButtonViewModel;

            this.nordicUartControlButtonViewModel.ButtonInPanel = clickedItem;
            if (this.nordicUartControlButtonViewModel.IsOnEditModel)
            {
                // flyout choose button and edit
                FlyoutBase.SetAttachedFlyout(this.editButton, buttonSelectionFlyout);
                FlyoutBase.ShowAttachedFlyout(this.editButton);
                this.editButton.Visibility       = Windows.UI.Xaml.Visibility.Collapsed;
                this.disconnectButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                this.CommandTextbox.Text         = clickedItem.Title;
                if (clickedItem.ButtonId != string.Empty)
                {
                    this.nordicUartControlButtonViewModel.ChangeColorOnSelectedItem(clickedItem.ButtonId);
                    this.nordicUartControlButtonViewModel.SelectedAvailableButton = clickedItem;
                }
            }
            else
            {
                //send the commands
                var item = await this.nordicUartControlButtonViewModel.TalkTo(clickedItem.Title.Trim());

                if (item != null)
                {
                    DialogUpdate(item);
                }
            }
        }
Exemplo n.º 2
0
        public void lead()
        {
            cur.Leading = true;
            Flyout fly = new Flyout();

            fly.FlyoutPresenterStyle = FlyoutStyle;
            StackPanel tempPanel = new StackPanel();
            TextBlock  tempTitle = new TextBlock(), tempContent = new TextBlock();
            Button     BTNnext = new Button();

            BTNnext.Content             = "next";
            BTNnext.Background          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            BTNnext.Click              += LeadNext;
            BTNnext.HorizontalAlignment = HorizontalAlignment.Right;
            tempTitle.FontSize          = 24;
            tempContent.FontSize        = 15;
            tempTitle.Text              = "GENERATE YOUR QUERY";
            tempContent.Text            = "Input your query with this search box on top";
            tempContent.TextWrapping    = TextWrapping.WrapWholeWords;
            tempContent.MaxWidth        = 350;
            tempPanel.Children.Add(tempTitle);
            tempPanel.Children.Add(tempContent);
            tempPanel.Children.Add(BTNnext);
            fly.Content = tempPanel;
            FlyoutBase.SetAttachedFlyout(this, fly);
            Flyout.ShowAttachedFlyout(this);
        }
Exemplo n.º 3
0
        private void LeadNext1(object sender, RoutedEventArgs e)
        {
            cur.quitLead1();
            cur.lead2();
            Flyout fly = new Flyout();

            fly.FlyoutPresenterStyle = FlyoutStyle;
            StackPanel tempPanel = new StackPanel();
            TextBlock  tempTitle = new TextBlock(), tempContent = new TextBlock();
            Button     BTNnext = new Button();

            BTNnext.Content             = "next";
            BTNnext.Background          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            BTNnext.Click              += LeadNext2;
            BTNnext.HorizontalAlignment = HorizontalAlignment.Right;
            tempTitle.FontSize          = 24;
            tempContent.FontSize        = 15;
            tempTitle.Text              = "WANT A HINT?";
            tempContent.TextWrapping    = TextWrapping.WrapWholeWords;
            tempContent.MaxWidth        = 350;
            tempContent.Text            = "Click this 'hint' button to get some hint about the keyword selected," +
                                          "you would get some keyword in same topic, which may help you generate" +
                                          "your query more easily";
            tempPanel.Children.Add(tempTitle);
            tempPanel.Children.Add(tempContent);
            tempPanel.Children.Add(BTNnext);
            fly.Content = tempPanel;
            FlyoutBase.SetAttachedFlyout(cur, fly);
            Flyout.ShowAttachedFlyout(cur);
        }
Exemplo n.º 4
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            p = (e.OriginalSource as FrameworkElement).DataContext as PlaylistItem;

            FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["DeletePlaylistFlyout"]);
            FlyoutBase.ShowAttachedFlyout(this);
        }
Exemplo n.º 5
0
        public async Task When_Attached_To_TextBlock_Check_Placement()
        {
            var(flyout, content) = CreateFlyout();

            const double MarginValue = 105;
            var          target      = new TextBlock
            {
                Margin = new Thickness(MarginValue),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Text = "Tweetle beetle battle"
            };

            TestServices.WindowHelper.WindowContent = target;

            await TestServices.WindowHelper.WaitForLoaded(target);

            try
            {
                FlyoutBase.SetAttachedFlyout(target, flyout);
                FlyoutBase.ShowAttachedFlyout(target);

                await TestServices.WindowHelper.WaitForLoaded(content);

                var contentCenter = content.GetOnScreenBounds().GetCenter();
                var targetCenter  = target.GetOnScreenBounds().GetCenter();

                Assert.IsTrue(targetCenter.X > MarginValue);
                Assert.AreEqual(targetCenter.X, contentCenter.X, delta: 2);
            }
            finally
            {
                flyout.Hide();
            }
        }
Exemplo n.º 6
0
        private void TopBarRemoteStorage(FrameworkElement sender)
        {
            var menuFlyout = CreateRemoteDrivesMenuFlyout();

            switch (menuFlyout.Items.Count)
            {
            case 0:
                UpdateTopBar();
                break;

            case 1:     // Transit directly if a single candidate is available
                var menu = menuFlyout.Items[0];
#if DEBUG
                if (!(menu is RemoteStorageMenuFlyoutItem))
                {
                    DummyStorageSelected();
                    break;
                }
#endif
                RemoteStorageSelected(menu as RemoteStorageMenuFlyoutItem);
                break;

            default:
                FlyoutBase.SetAttachedFlyout(sender, menuFlyout);
                FlyoutBase.ShowAttachedFlyout(sender);
                break;
            }
        }
Exemplo n.º 7
0
 private void edit_Click(object sender, RoutedEventArgs e)
 {
     editArtist.Text = artist;
     editTitle.Text  = title;
     FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["EditFlyout"]);
     FlyoutBase.ShowAttachedFlyout(this);
 }
Exemplo n.º 8
0
        private void InitAppBar()
        {
            StringResources stx = StringResources.Load("AppBar", "ContextMenu", "AppResources");

            // Major Controls
            FavBtn        = UIAliases.CreateAppBarBtn(Symbol.Favorite, "");
            FavBtn.Click += AddOrRemoveFav;

            TOCBtn        = UIAliases.CreateAppBarBtn(Symbol.OpenWith, stx.Text("TOC"));
            TOCBtn.Click += TOCBtn_Click;

            // Comment Button
            CommentBtn = UIAliases.CreateAppBarBtn(Symbol.Comment, stx.Text("Comments", "AppResources"));

            // Minor Controls
            AppBarButton ThemeBtn = UIAliases.CreateAppBarBtn(Symbol.Caption, stx.Text("CustomBackground", "ContextMenu"));

            ThemeBtn.Click += (s, e) => { FlyoutBase.ShowAttachedFlyout(ThemeBtn); };

            FlyoutBase.SetAttachedFlyout(ThemeBtn, ( MenuFlyout )Resources["ThemeFlyout"]);

            BrowserBtn        = UIAliases.CreateAppBarBtn(Symbol.Globe, stx.Text("OpenInBrowser"));
            BrowserBtn.Click += BrowserBtn_Click;

            MajorControls = new ICommandBarElement[] { FavBtn, TOCBtn };
            MinorControls = new ICommandBarElement[] { ThemeBtn, BrowserBtn };
        }
Exemplo n.º 9
0
        private void LeadNext(object sender, RoutedEventArgs e)
        {
            cur.lead1();
            Flyout fly = new Flyout();

            fly.FlyoutPresenterStyle = FlyoutStyle;
            StackPanel tempPanel = new StackPanel();
            TextBlock  tempTitle = new TextBlock(), tempContent = new TextBlock();
            Button     BTNnext = new Button();

            BTNnext.Content             = "next";
            BTNnext.Background          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            BTNnext.Click              += LeadNext1;
            BTNnext.HorizontalAlignment = HorizontalAlignment.Right;
            tempTitle.FontSize          = 20;
            tempContent.FontSize        = 15;
            tempContent.TextWrapping    = TextWrapping.WrapWholeWords;
            tempContent.MaxWidth        = 350;
            tempTitle.Text              = "IMPORTANCE LEVEL OF THE KEYWORD";
            tempContent.Text            = "When a keyword is selected, use key 'up' and 'down' " +
                                          "to change this keyword's level of importance; the keyword" +
                                          "turn to red to reveal that its way more important in this query" +
                                          "than other keyword";
            tempPanel.Children.Add(tempTitle);
            tempPanel.Children.Add(tempContent);
            tempPanel.Children.Add(BTNnext);
            fly.Content = tempPanel;
            FlyoutBase.SetAttachedFlyout(cur, fly);
            Flyout.ShowAttachedFlyout(cur);
        }
        /// <summary>
        /// Session Edit button event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void appBtnEditSession_Click(object sender, RoutedEventArgs e)
        {
            cdEditSession newEditSessionDialog = new cdEditSession((Session)session_list.SelectedItem);
            await newEditSessionDialog.ShowAsync();

            if (newEditSessionDialog.result == cdResult.UpdateSuccess)
            {
                refreshSessionList();  // Refresh the listview

                // Display notification of updated subject
                FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["notifyFlyout_updated"]);
                FlyoutBase.ShowAttachedFlyout(this);
            }
            else if (newEditSessionDialog.result == cdResult.UpdateFail)
            {
                // Display notification of error
                FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["notifyFlyout_error"]);
                FlyoutBase.ShowAttachedFlyout(this);
            }
            else if (newEditSessionDialog.result == cdResult.UpdateCancel)
            {
                // Add failed.
                // Prompt User
            }
        }
Exemplo n.º 11
0
        private void AddFlyoutToElement(FrameworkElement element, ImageAnalyzer analysisResult)
        {
            //show overlay
            var faces   = analysisResult.AnalysisResult.Faces?.Select(i => new FaceOverlayInfo(i, GetCelebrity(i, analysisResult.AnalysisResult))).ToArray() ?? Enumerable.Empty <FaceOverlayInfo>().ToArray();
            var objects = analysisResult.AnalysisResult.Objects?.Select(i => new ObjectOverlayInfo(i)).ToArray() ?? Enumerable.Empty <ObjectOverlayInfo>();
            var brands  = analysisResult.AnalysisResult.Brands?.Select(i => new ObjectOverlayInfo(i)).ToArray() ?? Enumerable.Empty <ObjectOverlayInfo>();
            var content = new VisionApiOverlayPresenter()
            {
                EnableHoverSelection = false,
                Width      = 400,
                FaceInfo   = faces,
                ObjectInfo = objects.Concat(brands).ToArray()
            };

            FlyoutBase.SetAttachedFlyout(element, new Flyout {
                Content = content
            });

            element.PointerReleased += async(s, e) =>
            {
                content.Source = null;
                content.Source = await analysisResult.GetImageSource();

                FlyoutBase.ShowAttachedFlyout(element);
            };
        }
Exemplo n.º 12
0
 private async void ButtonOpenWithWarningConfirm_Click(object sender, RoutedEventArgs e)
 {
     await RunOnUIThreadAsync(CoreDispatcherPriority.High, () =>
     {
         FlyoutOpenWithWarning.Hide();
         PrepareOpenWithFlyoutApps();
         FlyoutBase.SetAttachedFlyout(ButtonToolbarOpenWith, MenuFlyoutOpenWith);
         FlyoutBase.ShowAttachedFlyout(ButtonToolbarOpenWith);
     });
 }
Exemplo n.º 13
0
        //_______________________________
        //-------------------------------
        // -->> Flyout notifications <<--
        //_______________________________________________
        // Shows a Flyout with the message at the element
        //_______________________________________________
        public void notifyFlyout(string message, FrameworkElement element)
        {
            Flyout flyout           = new Flyout();
            var    messageTextBlock = new TextBlock();

            messageTextBlock.Text = message;
            flyout.Content        = messageTextBlock;
            flyout.Placement      = FlyoutPlacementMode.Bottom;
            FlyoutBase.SetAttachedFlyout(element, flyout);
            Flyout.ShowAttachedFlyout(element);
        }
Exemplo n.º 14
0
        public void OpenPopups_Flyouts_Unique()
        {
            var button = new Windows.UI.Xaml.Controls.Button();
            var flyout = new Flyout();

            FlyoutBase.SetAttachedFlyout(button, flyout);
            WindowHelper.WindowContent = button;
            Assert.AreEqual(0, VisualTreeHelper.GetOpenPopups(Window.Current).Count);
            FlyoutBase.ShowAttachedFlyout(button);
            Assert.AreEqual(1, VisualTreeHelper.GetOpenPopups(Window.Current).Count);
            flyout.Hide();
            Assert.AreEqual(0, VisualTreeHelper.GetOpenPopups(Window.Current).Count);
        }
        private void AddFlyoutToElement(FrameworkElement element, Image toolTip)
        {
            if (toolTip != null)
            {
                FlyoutBase.SetAttachedFlyout(element, new Flyout {
                    Content = toolTip
                });

                element.PointerReleased += (s, e) =>
                {
                    FlyoutBase.ShowAttachedFlyout(element);
                };
            }
        }
Exemplo n.º 16
0
        public override void DisturbedEvent(PhysicObject sender, PhysicObject physicObject)
        {
            StackPanel s = new StackPanel();
            //s.Children.Add(ImageView.ImageSet());
            TextBlock t = new TextBlock()
            {
                Text = "NPC",
            };

            s.Children.Add(t);
            Flt.Content = s;
            FlyoutBase.SetAttachedFlyout(sender.Container, Flt);
            FlyoutBase.ShowAttachedFlyout(sender.Container);
        }
Exemplo n.º 17
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            NewSmartPlaylistViewModel ViewModel = (NewSmartPlaylistViewModel)DataContext;

            if (ViewModel.IsCorrect())
            {
                ViewModel.SaveSmartPlaylist();
            }
            else
            {
                FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["ErrorFlyout"]);
                FlyoutBase.ShowAttachedFlyout(this);
            }
        }
Exemplo n.º 18
0
        // 在 CodeBehind 中创建 FlyoutBase 控件后,将其绑定到指定的控件上,并显示
        private void textBlock3_Tapped(object sender, TappedRoutedEventArgs e)
        {
            TextBlock flyoutContent = new TextBlock();

            flyoutContent.Text = "我是 Flyout 中的内容";

            Flyout flyout = new Flyout();

            flyout.Placement = FlyoutPlacementMode.Right;
            flyout.Content   = flyoutContent;

            FlyoutBase.SetAttachedFlyout(textBlock3, flyout);
            FlyoutBase.ShowAttachedFlyout(textBlock3);
        }
Exemplo n.º 19
0
        private void SelectAndOpenColorPicker(FrameworkElement colorPaletteItemGrid)
        {
            var colorPaletteItem = colorPaletteItemGrid.DataContext as ColorPaletteItem;

            ViewModel.SelectItem(colorPaletteItem);
            ColorChanged?.Invoke(this,
                                 new PaletteColorChangedEventArgs {
                NewColor = colorPaletteItem.ColorBrush.Color
            });

            ColorPicker.Color         = colorPaletteItem.ColorBrush.Color;
            ColorPicker.PreviousColor = colorPaletteItem.ColorBrush.Color;
            FlyoutBase.SetAttachedFlyout(colorPaletteItemGrid, ColorPickerFlyout);
            FlyoutBase.ShowAttachedFlyout(colorPaletteItemGrid);
        }
Exemplo n.º 20
0
        void OpenContextMenu()
        {
            if (FlyoutBase.GetAttachedFlyout(CellContent) == null)
            {
                var flyout = new MenuFlyout();
                SetupMenuItems(flyout);

                ((INotifyCollectionChanged)Cell.ContextActions).CollectionChanged += OnContextActionsChanged;

                _contextActions = Cell.ContextActions;
                FlyoutBase.SetAttachedFlyout(CellContent, flyout);
            }

            FlyoutBase.ShowAttachedFlyout(CellContent);
        }
Exemplo n.º 21
0
        public async Task Should_Close_Open_Flyouts()
        {
            var button = new Windows.UI.Xaml.Controls.Button();
            var flyout = new Flyout();

            FlyoutBase.SetAttachedFlyout(button, flyout);
            WindowHelper.WindowContent = button;
            Assert.AreEqual(0, GetNonMessageDialogPopupsCount());
            FlyoutBase.ShowAttachedFlyout(button);
            Assert.AreEqual(1, GetNonMessageDialogPopupsCount());
            var messageDialog  = new MessageDialog("Should_Close_Open_Popups");
            var asyncOperation = messageDialog.ShowAsync();

            Assert.AreEqual(0, GetNonMessageDialogPopupsCount());
            asyncOperation.Cancel();
        }
Exemplo n.º 22
0
        public override void DisturbedEvent(PhysicObject sender, PhysicObject p)
        {

            StackPanel s = new StackPanel();
            s.Children.Add(ImageView.ImageSet(Item.Path));
            TextBlock t = new TextBlock()
            {
                Text = "Click E to add to you inventory",
            };
            s.Children.Add(t);
            Fl.Content = s;
            FlyoutBase.SetAttachedFlyout(p.Container, Fl);
            FlyoutBase.ShowAttachedFlyout(p.Container);


        }
Exemplo n.º 23
0
        public async Task Should_Close_Open_Popups()
        {
            var button = new Windows.UI.Xaml.Controls.Button();
            var flyout = new Flyout();

            FlyoutBase.SetAttachedFlyout(button, flyout);
            WindowHelper.WindowContent = button;
            Assert.AreEqual(0, VisualTreeHelper.GetOpenPopups(Window.Current).Count);
            FlyoutBase.ShowAttachedFlyout(button);
            Assert.AreEqual(1, VisualTreeHelper.GetOpenPopups(Window.Current).Count);
            var messageDialog  = new MessageDialog("Hello");
            var asyncOperation = messageDialog.ShowAsync();

            Assert.AreEqual(0, VisualTreeHelper.GetOpenPopups(Window.Current).Count);
            asyncOperation.Cancel();
        }
Exemplo n.º 24
0
 private async void ButtonToolbarOpenWith_Click(object sender, RoutedEventArgs e)
 {
     await RunOnUIThreadAsync(CoreDispatcherPriority.Low, () =>
     {
         if (ViewModel.ShowOpenWithWarning)
         {
             FlyoutBase.SetAttachedFlyout((FrameworkElement)sender, FlyoutOpenWithWarning);
         }
         else
         {
             PrepareOpenWithFlyoutApps();
             FlyoutBase.SetAttachedFlyout((FrameworkElement)sender, MenuFlyoutOpenWith);
         }
         FlyoutBase.ShowAttachedFlyout((AppBarButton)sender);
     });
 }
Exemplo n.º 25
0
        void Show()
        {
            if (Element?.Anchor != null)
            {
                var anchor = Platform.GetRenderer(Element.Anchor).ContainerElement;
                FlyoutBase.SetAttachedFlyout(anchor, this);
                FlyoutBase.ShowAttachedFlyout(anchor);
            }
            else
            {
                var frameworkElement = Platform.GetRenderer(Element?.Parent as VisualElement)?.ContainerElement;
                FlyoutBase.SetAttachedFlyout(frameworkElement, this);
                FlyoutBase.ShowAttachedFlyout(frameworkElement);
            }

            Element?.OnOpened();
        }
Exemplo n.º 26
0
        public async Task Check_Placement_All_MenuFlyout(
            FlyoutPlacementMode placementMode,
            HorizontalPosition horizontalPosition,
            VerticalPosition verticalPosition)
        {
            var flyout = CreateBasicMenuFlyout();

            flyout.Placement = placementMode;

            const double MarginValue = 97;
            const int    TargetWidth = 88;
            var          target      = new Border
            {
                Margin = new Thickness(MarginValue),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width      = TargetWidth,
                Height     = 23,
                Background = new SolidColorBrush(Colors.Red)
            };

            TestServices.WindowHelper.WindowContent = target;

            await TestServices.WindowHelper.WaitForLoaded(target);

            await TestServices.WindowHelper.WaitFor(() => target.ActualWidth == TargetWidth);             // For some reason target is initially stretched on iOS

            try
            {
                FlyoutBase.SetAttachedFlyout(target, flyout);
                FlyoutBase.ShowAttachedFlyout(target);

                var presenter = flyout.Presenter;

                await TestServices.WindowHelper.WaitForLoaded(presenter);

                var content = presenter.FindFirstChild <ScrollViewer>();

                VerifyRelativeContentPosition(horizontalPosition, verticalPosition, content, MarginValue, target);
            }
            finally
            {
                flyout.Hide();
            }
        }
Exemplo n.º 27
0
        private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Flyout fly = new Flyout();

            fly.FlyoutPresenterStyle = new Style(typeof(FlyoutPresenter));
            WrapPanel tempPanel = new WrapPanel();

            tempPanel.Orientation = Orientation.Horizontal;
            foreach (var kw in _kws)
            {
                AssociateT2Control t = new AssociateT2Control(kw, false);
                t.Margin = new Thickness(5);
                tempPanel.Children.Add(t);
            }
            fly.Content = tempPanel;
            FlyoutBase.SetAttachedFlyout(this, fly);
            Flyout.ShowAttachedFlyout(this);
        }
 protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e)
 {
     base.OnElementChanged(e);
     if (Control != null)
     {
         // TODO: Focus() doesn't open date picker popup on UWP, it's known issue
         // on Xamarin.Forms and should be fixed in 2.5. Had to open it manually.
         var flyout = new DatePickerFlyout()
         {
             Placement = FlyoutPlacementMode.Top
         };
         flyout.DatePicked += (s, args) =>
         {
             Control.Date = args.NewDate;
         };
         FlyoutBase.SetAttachedFlyout(Control, flyout);
     }
 }
        /// <summary>
        /// Content Dialog Save Click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            newSub       = new Subject(txtFirstName.Text, txtLastName.Text);
            newSub.image = imgTemp;
            newSub.setImage(bitmapImage);

            using (var db = new DataModel.UberEversolContext())
            {
                db.Subjects.Add(newSub);
                db.SaveChanges();
            }

            result = cdResult.AddSuccess;

            FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["notifyFlyout"]);
            FlyoutBase.ShowAttachedFlyout(this);
            FlyoutBase.GetAttachedFlyout(this).Hide();
        }
Exemplo n.º 30
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                ((MyDatePicker2)Element).ShowDatePicker = new Action(() =>
                {
                    if (((MyDatePicker2)Element).ManualMinDate)
                    {
                        flyout.MinYear = DateTime.SpecifyKind(((MyDatePicker2)Element).MinimumDate, DateTimeKind.Unspecified);
                    }
                    if (((MyDatePicker2)Element).ManualMaxDate)
                    {
                        flyout.MaxYear = DateTime.SpecifyKind(((MyDatePicker2)Element).MaximumDate, DateTimeKind.Unspecified);
                    }

                    flyout.DatePicked -= Flyout_DatePicked;
                    flyout.Date        = Control.Date;
                    flyout.DatePicked += Flyout_DatePicked;
                    FlyoutBase.ShowAttachedFlyout(Control);
                });
                var minYear = DateTime.SpecifyKind(new DateTime(1919, 01, 01), DateTimeKind.Unspecified);
                if (((MyDatePicker2)Element).ManualMinDate)
                {
                    minYear = DateTime.SpecifyKind(((MyDatePicker2)Element).MinimumDate, DateTimeKind.Unspecified);
                }
                var maxYear = DateTime.SpecifyKind(new DateTime(DateTime.MaxValue.Year, DateTime.MaxValue.Month, DateTime.MaxValue.Day), DateTimeKind.Unspecified);
                if (((MyDatePicker2)Element).ManualMaxDate)
                {
                    maxYear = DateTime.SpecifyKind(((MyDatePicker2)Element).MaximumDate, DateTimeKind.Unspecified);
                }
                // TODO: Focus() doesn't open date picker popup on UWP, it's known issue
                // on Xamarin.Forms and should be fixed in 2.5. Had to open it manually.
                flyout = new DatePickerFlyout()
                {
                    Placement = FlyoutPlacementMode.Bottom, MaxYear = maxYear, MinYear = minYear
                };
                flyout.DatePicked += Flyout_DatePicked;
                FlyoutBase.SetAttachedFlyout(Control, flyout);
            }
        }