Пример #1
0
        public override void OnApplyTemplate()
        {
            foreach (var key in Enum.GetValues(typeof(ToggleButtonType)).Cast <ToggleButtonType>())
            {
                var name      = key.ToString();
                var tabButtom = GetRequiredTemplateChild <ToggleButton>(name);
                if (tabButtom == null)
                {
                    throw new Exception($"Template Missing ToggleButton with name '{name}'. Make sure your Sytle template contains ToggleButton with name '{name}'.");
                }
                tabButtom.Click    += TabButtonButton_Click;
                tabButtom.IsEnabled = false;
                if (HideInitTabButtonVisibility(name))
                {
                    tabButtom.Visibility = Visibility.Hidden;
                }
                WindowUtils.Translate(tabButtom.Content);
                Tabs[key] = tabButtom;
            }
            _gridLayoutRootOverlay = GetRequiredTemplateChild <Grid>("LayoutRootOverlay");
            _gridLayoutRootOverlay_MODAL_WINDOW             = GetRequiredTemplateChild <Grid>("MODAL_WINDOW_BLUR");
            _gridLayoutRootOverlay_MODAL_WINDOW_ContentGrid = GetRequiredTemplateChild <Grid>("MODAL_WINDOW_ContentGrid");

            _gridLayoutRootOverlay_MODAL_WINDOW_ContentGrid.MouseDown += _gridLayoutRootOverlay_MouseDown;
            _gridLayoutRootOverlay_MODAL_WINDOW.MouseDown             += _gridLayoutRootOverlay_MouseDown;
            _gridLayoutRootOverlay.MouseDown += _gridLayoutRootOverlay_MouseDown;

            _contentPresenter = GetRequiredTemplateChild <ContentPresenter>("MODAL_DIALOG");
            if (_contentPresenter != null)
            {
                _contentPresenter.AddHandler(Grid.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.OnHeaderBarMouseLeftButtonDown));
            }
            base.OnApplyTemplate();
        }
Пример #2
0
        private object CreateViewInstance()
        {
            if (this.IsInDesignMode())
            {
                var designTimeBlankContainer = new Grid
                {
                    Background = new SolidColorBrush(Color.FromArgb(50, 120, 120, 120)),
                };
                if (_customDataTemplate.DesignWidth.HasValue)
                {
                    designTimeBlankContainer.Width = _customDataTemplate.DesignWidth.Value;
                }
                if (_customDataTemplate.DesignHeight.HasValue)
                {
                    designTimeBlankContainer.Height = _customDataTemplate.DesignHeight.Value;
                }

                var formatText = _customDataTemplate.Description;
                designTimeBlankContainer.Children.Add(new TextBlock
                {
                    Text = formatText,
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center
                });

                return(designTimeBlankContainer);
            }

            var container = new ContentPresenter
            {
                Content = _customDataTemplate.CreateView()
            };

            container.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(LoadedRoutedEventHandler));
            container.AddHandler(FrameworkElement.UnloadedEvent, new RoutedEventHandler(UnloadedRoutedEventHandler));

            return(container);
        }