Inheritance: Windows.UI.Xaml.Controls.RadioButton
Beispiel #1
0
        private static FrameworkElement GetHeaderContainer(TabHeaderItem header)
        {
            var container = header.Children().OfType <Panel>().FirstOrDefault();

            if (container == null)
            {
                var textBlock = header.Children().OfType <TextBlock>().FirstOrDefault();

                if (textBlock == null)
                {
                    throw new NullReferenceException("No header content found.");
                }

                return(textBlock);
            }

            return(container);
        }
Beispiel #2
0
 private int GetHeaderIndex(TabHeaderItem header)
 {
     return(Headers.IndexOf(header));
 }
Beispiel #3
0
 private TextBlock GetHeaderTextBlock(TabHeaderItem header)
 {
     return(header.GetChildByName <TextBlock>("Header"));
 }
Beispiel #4
0
        private void OnTabLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnTabLoaded;

            for (int i = 0; i < Items.Count; i++)
            {
                var tabItem = ContainerFromIndex(i) as TabItem;

                if (tabItem != null)
                {
                    var header = new TabHeaderItem
                    {
                        Content         = tabItem.Header,
                        ContentTemplate = HeaderTemplate,
                        IsChecked       = i == 0
                    };

                    // Have to do this to avoid a bug where RadioButton's GroupName
                    // doesn't function properly after Reloaded.
                    header.Loaded += async(s, args) =>
                    {
                        // TODO: There should be a better way to handle this, at system level??
                        // Put a short delay here to allow the system to calculate the Offset
                        // before we can animate it.
                        await Task.Delay(1000);

                        _isLoaded = true;

                        var h = (TabHeaderItem)s;
                        h.GroupName = "Headers";

                        UpdateHeaderVisuals();
                        SyncUnderlineVisual();
                    };
                    header.Unloaded += (s, args) =>
                    {
                        var h = (TabHeaderItem)s;
                        h.GroupName = string.Empty;
                    };

                    header.Checked += (s, args) =>
                    {
                        UpdateHeaderVisuals();

                        var h = (TabHeaderItem)s;
                        SelectedIndex = GetHeaderIndex(h);
                    };
                    header.Unchecked += (s, args) =>
                    {
                        UpdateHeaderVisuals();
                    };

                    header.SizeChanged += (s, args) =>
                    {
                        if (_isLoaded)
                        {
                            UpdateHeaderVisuals();
                            SyncUnderlineVisual();
                        }
                    };

                    Headers.Add(header);
                }
            }
        }
Beispiel #5
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;

            if (Items == null)
            {
                return;
            }

            SetSelectedHeaderIndicatorVisualBoundaries();

            for (var i = 0; i < Items.Count; i++)
            {
                var tabItem = ContainerFromIndex(i) as TabItem;

                if (tabItem == null)
                {
                    continue;
                }

                var header = new TabHeaderItem
                {
                    DataContext     = Items[i],
                    Content         = tabItem.Header,
                    HeaderIconStyle = tabItem.HeaderIconStyle,
                    ContentTemplate = HeaderTemplate,
                    IsChecked       = i == 0
                };

                // Have to do this to avoid a bug where RadioButton's GroupName
                // doesn't function properly after Reloaded.
                header.Loaded += async(s, args) =>
                {
                    // TODO: There should be a better way to handle this, at system level??
                    // Put a short delay here to allow the system to calculate the Offset
                    // before we can animate it.
                    await Task.Delay(1000);

                    _isLoaded = true;

                    var h = (TabHeaderItem)s;
                    h.GroupName = "Headers";

                    UpdateHeaderVisuals();
                    SyncSelectedHeaderIndicatorVisual();
                };
                header.Unloaded += (s, args) =>
                {
                    var h = (TabHeaderItem)s;
                    h.GroupName = string.Empty;
                };

                header.Checked += async(s, args) =>
                {
                    UpdateHeaderVisuals();

                    var h = (TabHeaderItem)s;
                    SelectedIndex = GetHeaderIndex(h);

                    // TODO: We might be able to monitor the scrolling on the HeadersPanelHost and sync the selection visual with the scrolling in real time.
                    // OnHeadersPanelHostDirectManipulationStarted(null, null);
                    await HeadersPanelHost.ScrollToElementAsync(header, false, bringToTopOrLeft : false);

                    SyncSelectedHeaderIndicatorVisual();
                };
                header.Unchecked += (s, args) =>
                {
                    UpdateHeaderVisuals();
                };

                header.SizeChanged += (s, args) =>
                {
                    if (!_isLoaded)
                    {
                        return;
                    }

                    UpdateHeaderVisuals();
                    SyncSelectedHeaderIndicatorVisual();
                };

                Headers.Add(header);
            }
        }