Exemplo n.º 1
0
        private void StackColumnElement(FrameworkElementFactory columnElement, ColumnData cd)
        {
            FrameworkElementFactory inputElement = this.CreateStackElement(cd);

            if (inputElement != null)
            {
                columnElement.AppendChild(inputElement);
            }
        }
Exemplo n.º 2
0
        public virtual ToolTip GetToolTip(double height)
        {
            if (h.thumbnail.preview_img == null)
            {
                return(null);
            }
            if (!thumbNail.IsVisible)
            {
                return(null);
            }
            //b = 비율
            //Magnif = 배율
            //double b = height / h.thumbnail.preview_img.Height;
            double top        = thumbNail.PointToScreen(new Point(0, 0)).Y;
            double bottom     = top + thumbNail.ActualHeight;
            double WorkHeight = SystemParameters.WorkArea.Bottom;
            double MagnifSize = height * Global.Magnif;
            double Len        = WorkHeight / 2 - (bottom - thumbNail.ActualHeight / 2);
            bool   up         = Len <= 0;
            double VisualMaxSize;

            if (up)
            {
                VisualMaxSize = top;
            }
            else
            {
                VisualMaxSize = WorkHeight - bottom;
            }
            double size = MagnifSize > VisualMaxSize ? VisualMaxSize : MagnifSize;
            FrameworkElementFactory image = new FrameworkElementFactory(typeof(Image));
            {
                image.SetValue(Image.HeightProperty, size);
                image.SetValue(Image.HorizontalAlignmentProperty, HorizontalAlignment.Left);
                image.SetValue(Image.SourceProperty, h.thumbnail.preview_img.ToImage());
            }
            FrameworkElementFactory elemborder = new FrameworkElementFactory(typeof(Border));
            {
                elemborder.SetValue(Border.BorderThicknessProperty, new Thickness(1));
                elemborder.SetValue(Border.BorderBrushProperty, new SolidColorBrush(Global.outlineclr));
                elemborder.AppendChild(image);
            }
            FrameworkElementFactory panel = new FrameworkElementFactory(typeof(StackPanel));
            {
                panel.AppendChild(elemborder);
            }
            ToolTip toolTip = new ToolTip
            {
                Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom,
                Template  = new ControlTemplate
                {
                    VisualTree = panel
                }
            };

            return(toolTip);
        }
        private DataTemplate createCardioEditable(int setNumber)
        {
            var gridFactory = new FrameworkElementFactory(typeof(Grid));

            gridFactory.SetValue(Grid.BackgroundProperty, Brushes.Transparent);
            gridFactory.Name = "mainGrid";
            var column1 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column1.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star));
            var column2 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column2.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Auto));

            gridFactory.AppendChild(column1);
            gridFactory.AppendChild(column2);

            FrameworkElementFactory factory = new FrameworkElementFactory(typeof(TimeSpanUpDown));
            Binding b = new Binding(setNumber + ".CardioValue");

            b.Mode                = BindingMode.TwoWay;
            b.Converter           = new TimeSpanConverter();
            b.UpdateSourceTrigger = UpdateSourceTrigger.Default;
            factory.SetValue(DateTimeUpDown.ValueProperty, b);


            var buttonsPaneFactory = new FrameworkElementFactory(typeof(StackPanel));

            buttonsPaneFactory.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);


            var btnDetails = new FrameworkElementFactory(typeof(Button));

            btnDetails.SetValue(Button.WidthProperty, 10.0);
            //btnDetails.SetValue(Button.HeightProperty, 10.0);
            btnDetails.SetValue(Button.IsTabStopProperty, false);

            btnDetails.SetValue(Button.ContentProperty, "..");
            btnDetails.SetValue(Button.PaddingProperty, new Thickness(0.0));
            btnDetails.SetValue(Button.StyleProperty, Application.Current.Resources["CloseableTabItemButtonStyle"]);


            btnDetails.AddHandler(Button.ClickEvent, new RoutedEventHandler(btnAdditionalSetInfo_Click));
            btnDetails.SetValue(Button.ToolTipProperty, StrengthTrainingEntryStrings.usrStrengthTraining_Header_AdditionalInfo);
            buttonsPaneFactory.AppendChild(btnDetails);


            gridFactory.AppendChild(factory);
            gridFactory.AppendChild(buttonsPaneFactory);

            buttonsPaneFactory.SetValue(Grid.ColumnProperty, 1);
            // Create the template itself, and add the factory to it.
            DataTemplate cellEditingTemplate = new DataTemplate();

            cellEditingTemplate.VisualTree = gridFactory;

            return(cellEditingTemplate);
        }
Exemplo n.º 4
0
        private void AddTextBlockFactory(FrameworkElementFactory parent, string content)
        {
            var tbFactory = new FrameworkElementFactory(typeof(TextBlock));

            tbFactory.SetValue(TextBlock.TextProperty, content);
            tbFactory.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            tbFactory.SetValue(TextBlock.ForegroundProperty, new SolidColorBrush(Color.FromRgb(109, 109, 109)));
            parent.AppendChild(tbFactory);
        }
Exemplo n.º 5
0
        private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            SampleView view = new SampleView();

            view.LabelText = "A new view #" + (this.tabControl.Items.Count).ToString();

            FabTabItem item = new FabTabItem();

            Uri         uri    = new Uri("pack://application:,,/SampleProject;component/Graphics/tab_icon.gif", UriKind.RelativeOrAbsolute);
            BitmapImage bitmap = new BitmapImage(uri);

            //need to create these element factories to build up the datatemplates completely in code.
            //This would be much easier to define in XAML, but doing it here for demonstration purposes.
            //For more info on how this works see: http://stackoverflow.com/questions/248362/how-do-i-build-a-datatemplate-in-c-code
            FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel));

            spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            FrameworkElementFactory imgFactory = new FrameworkElementFactory(typeof(Image));

            imgFactory.SetValue(Image.SourceProperty, bitmap);

            FrameworkElementFactory tbFactory = new FrameworkElementFactory(typeof(TextBlock));

            //Very important to bind something in our datatemplate to the actual header so that it will show up.
            tbFactory.SetBinding(TextBlock.TextProperty, new Binding("."));

            spFactory.AppendChild(imgFactory);
            spFactory.AppendChild(tbFactory);

            DataTemplate headerTemplate = new DataTemplate();

            //set the datatemplate's visual tree to the root frameworkelementfactory.
            headerTemplate.VisualTree = spFactory;

            //build the visual tree for the HeaderTemplate, but the header itself needs to remain a string
            //if we want a meaningful string to show up for the screenshot headers on the ContentTabView
            //and meaningful tab header names to show up in the ContentTab dropdown.
            item.HeaderTemplate = headerTemplate;
            item.Header         = view.LabelText;
            item.Content        = view;

            this.tabControl.Items.Add(item);
        }
Exemplo n.º 6
0
        public GameStatistics()
        {
            InitializeComponent();

            int totalColumnIndex = this.dataGrid.Columns.IndexOf(this.classColumnsPlaceholder);

            foreach (DeckAttributes da in ClassAttributesHelper.Classes.Values)
            {
                DataGridTextColumn col = new DataGridTextColumn();
                col.Header      = da.ToString();
                col.Binding     = new Binding(da.ToString());
                col.CanUserSort = false;

                DataTemplate cardLayout = new DataTemplate();
                cardLayout.DataType = typeof(GameStatistics);

                //set up the stack panel
                FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel));
                spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
                spFactory.SetValue(StackPanel.ToolTipProperty, da.ToString());

                //set up the card holder textblock
                FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(Image));
                cardHolder.SetValue(Image.SourceProperty, new BitmapImage(new Uri(da.ImageSources.First(), UriKind.Absolute)));
                cardHolder.SetValue(Image.WidthProperty, 16.0);
                spFactory.AppendChild(cardHolder);

                if (da.ImageSources.Count() > 1)
                {
                    //set up the card holder textblock
                    FrameworkElementFactory cardHolder2 = new FrameworkElementFactory(typeof(Image));
                    cardHolder2.SetValue(Image.SourceProperty, new BitmapImage(new Uri(da.ImageSources.Skip(1).FirstOrDefault(), UriKind.Absolute)));
                    cardHolder2.SetValue(Image.WidthProperty, 16.0);
                    spFactory.AppendChild(cardHolder2);
                }

                //set the visual tree of the data template
                cardLayout.VisualTree = spFactory;

                col.HeaderTemplate = cardLayout;

                this.dataGrid.Columns.Insert(++totalColumnIndex, col);
            }
        }
Exemplo n.º 7
0
        static FrameworkElementFactory CreateButtonChromeFactory()
        {
            var panel            = new FrameworkElementFactory(typeof(SWC.DockPanel));
            var contentPresenter = new FrameworkElementFactory(typeof(SWC.ContentPresenter));

            contentPresenter.SetValue(SWC.ContentPresenter.MarginProperty, new Thickness(2, 1, 0, 0));
            panel.AppendChild(contentPresenter);
            var path = new FrameworkElementFactory(typeof(System.Windows.Shapes.Path));

            path.SetValue(System.Windows.Shapes.Path.DataProperty, Geometry.Parse("M 0 0 L 3.5 4 L 7 0 Z"));
            path.SetValue(System.Windows.Shapes.Path.FillProperty, Brushes.Black);
            path.SetValue(System.Windows.Shapes.Path.HorizontalAlignmentProperty, HorizontalAlignment.Right);
            path.SetValue(System.Windows.Shapes.Path.VerticalAlignmentProperty, VerticalAlignment.Center);
            path.SetValue(System.Windows.Shapes.Path.MarginProperty, new Thickness(3, 1, 3, 0));
            path.SetValue(SWC.DockPanel.DockProperty, SWC.Dock.Right);
            panel.AppendChild(path);
            var buttonChromeFactory = new FrameworkElementFactory(typeof(Microsoft.Windows.Themes.ButtonChrome));

            buttonChromeFactory.SetBinding(Microsoft.Windows.Themes.ButtonChrome.BorderBrushProperty, new Binding("BorderBrush")
            {
                RelativeSource = RelativeSource.TemplatedParent
            });
            buttonChromeFactory.SetBinding(Microsoft.Windows.Themes.ButtonChrome.BackgroundProperty, new Binding("Background")
            {
                RelativeSource = RelativeSource.TemplatedParent
            });
            buttonChromeFactory.SetBinding(Microsoft.Windows.Themes.ButtonChrome.RenderMouseOverProperty, new Binding("IsMouseOver")
            {
                RelativeSource = RelativeSource.TemplatedParent
            });
            buttonChromeFactory.SetBinding(Microsoft.Windows.Themes.ButtonChrome.RenderPressedProperty, new Binding("IsPressed")
            {
                RelativeSource = RelativeSource.TemplatedParent
            });
            buttonChromeFactory.SetBinding(Microsoft.Windows.Themes.ButtonChrome.RenderDefaultedProperty, new Binding("Button.IsDefaulted")
            {
                RelativeSource = RelativeSource.TemplatedParent
            });
            buttonChromeFactory.SetValue(Microsoft.Windows.Themes.ButtonChrome.SnapsToDevicePixelsProperty, true);
            buttonChromeFactory.Name = "Chrome";
            buttonChromeFactory.AppendChild(panel);

            return(buttonChromeFactory);
        }
Exemplo n.º 8
0
        ControlTemplate DesignTextBox()
        {
            // Создание объекта ControlTemplate для Button
            ControlTemplate template = new ControlTemplate(typeof(Button));
            // Создание объекта FrameworkElementFactory для Border
            FrameworkElementFactory factoryBorder = new FrameworkElementFactory(typeof(Border));

            // Назначение имени для последующих ссылок
            factoryBorder.Name = "border";
            // Задание некоторых свойств по умолчанию
            factoryBorder.SetValue(Border.BorderBrushProperty, Brushes.Gray);
            factoryBorder.SetValue(Border.BorderThicknessProperty, new Thickness(3));
            factoryBorder.SetValue(Border.BackgroundProperty, SystemColors.ControlLightBrush);

            // Создание объекта FrameworkElementFactory для ContentPresenter
            FrameworkElementFactory factoryContent = new FrameworkElementFactory(typeof(ContentPresenter));

            // Назначение имени для последующих ссылок
            factoryContent.Name = "content";
            // Привязка свойств ContentPresenter к свойствам Button
            factoryContent.SetValue(ContentPresenter.ContentProperty, new TemplateBindingExtension(Button.ContentProperty));
            // Обратите внимание: свойство Padding кнопки
            // соответствует свойству Margin содержимого!
            factoryContent.SetValue(ContentPresenter.MarginProperty, new TemplateBindingExtension(Button.PaddingProperty));
            // Назначение ContentPresenter дочерним объектом Border
            factoryBorder.AppendChild(factoryContent);
            // Border назначается корневым узлом визуального дерева
            template.VisualTree = factoryBorder;
            // Определение триггера для условия IsMouseOver=true
            Trigger trig = new Trigger();

            trig.Property = UIElement.IsVisibleProperty;
            trig.Value    = true;
            // Связывание объекта Setter с триггером
            // для изменения свойства CornerRadius элемента Border.
            Setter set = new Setter();

            set.Property   = Border.CornerRadiusProperty;
            set.Value      = new CornerRadius(12);
            set.TargetName = "border";
            // Включение объекта Setter в коллекцию Setters триггера
            trig.Setters.Add(set);
            // Определение объекта Setter для изменения FontStyle.
            // (Для свойства кнопки задавать TargetName не нужно.)
            set          = new Setter();
            set.Property = Control.FontStyleProperty;
            set.Value    = FontStyles.Italic;
            // Добавление в коллекцию Setters того же триггера
            trig.Setters.Add(set);
            // Включение триггера в шаблон
            template.Triggers.Add(trig);
            // Включение триггера в шаблон
            template.Triggers.Add(trig);

            return(template);
        }
Exemplo n.º 9
0
        private void ApllyTemplate()
        {
            //SetValue(BackgroundProperty, Brushes.Chartreuse);
            SetValue(BackgroundProperty, Brushes.Transparent);
            SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Visible);


            var ip    = new ItemsPanelTemplate();
            var panel = new FrameworkElementFactory(typeof(WrapPanel));

            ip.VisualTree = panel;
            SetValue(ItemsPanelProperty, ip);


            //var templ = new ControlTemplate(typeof(TileBaseView));
            ControlTemplate template = new ControlTemplate(typeof(TileBaseView));
            var             grid     = new FrameworkElementFactory(typeof(Grid));

            var border = new FrameworkElementFactory(typeof(Border));

            //    border.SetValue(Border.BorderBrushProperty, Brushes.Crimson);
            //    border.SetValue(Border.BorderThicknessProperty, new Thickness(2.0));
            //border.SetValue(Border.WidthProperty, 2.0);
            //border.SetValue(Border.NameProperty, "mask");
            //    border.SetValue(Border.CornerRadiusProperty, new CornerRadius(5));
            grid.AppendChild(border);

            template.VisualTree = grid;
            //SetValue(TemplateProperty, template);


            var datatemplate = new DataTemplate(typeof(List <BitmapImage>));

            grid   = new FrameworkElementFactory(typeof(Grid));
            border = new FrameworkElementFactory(typeof(Border));
            border.SetValue(Border.BorderBrushProperty, Brushes.Black);
            border.SetValue(Border.BorderThicknessProperty, new Thickness(2.0));
            border.SetValue(Border.CornerRadiusProperty, new CornerRadius(5));
            border.SetValue(Border.MarginProperty, new Thickness(1.0, 1.0, 1.0, 1.0));
            grid.AppendChild(border);

            var image = new FrameworkElementFactory(typeof(Image));

            image.SetValue(Image.StretchProperty, Stretch.Fill);
            var imgsrs = new Binding();

            imgsrs.Path = new PropertyPath(_SourcePath);
            image.SetValue(Image.SourceProperty, imgsrs);
            image.SetValue(Image.WidthProperty, (double)ItemWidth);
            image.SetValue(Image.HeightProperty, (double)ItemHeight);
            border.AppendChild(image);

            datatemplate.VisualTree = grid;
            SetValue(ItemTemplateProperty, datatemplate);
        }
Exemplo n.º 10
0
        private static DataTemplate InitView_PluginsList_NameTemplate()
        {
            var stack = new FrameworkElementFactory(typeof(StackPanel));

            stack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            FrameworkElementFactory image;

            // IsPrimary Icon
            stack.AppendChild(image = new FrameworkElementFactory(typeof(Image)));
            image.SetValue(FrameworkElement.WidthProperty, 12.0);
            image.SetValue(FrameworkElement.HeightProperty, 12.0);
            image.SetValue(Image.StretchProperty, Stretch.Uniform);
            image.SetBinding(Image.SourceProperty, new Binding("IsPrimary")
            {
                Converter = new ValueConverter <bool?, ImageSource>(b => b != null ? ((bool)b ? _iconPluginPrimaryGlyph : _iconPluginThirdPartyGlyph) : null)
            });
            //image.SetValue(FrameworkElement.MarginProperty, new Thickness(0));
            image.SetBinding(FrameworkElement.ToolTipProperty, new Binding("IsPrimary")
            {
                Converter = new ValueConverter <bool?, string>(b => b != null ? ((bool)b ? Stringtable.PluginIsPrimary : Stringtable.PluginIsNotPrimary) : "")
            });
            image.SetValue(UIElement.OpacityProperty, .5);

            // Plugin Icon
            stack.AppendChild(image = new FrameworkElementFactory(typeof(Image)));
            image.SetValue(FrameworkElement.WidthProperty, 16.0);
            image.SetValue(FrameworkElement.HeightProperty, 16.0);
            image.SetValue(Image.StretchProperty, Stretch.Uniform);
            image.SetBinding(Image.SourceProperty, new Binding("Icon"));
            image.SetValue(FrameworkElement.MarginProperty, new Thickness(1));
            image.SetValue(FrameworkElement.ToolTipProperty, Stringtable.PluginIcon);

            FrameworkElementFactory text;

            stack.AppendChild(text = new FrameworkElementFactory(typeof(TextBlock)));
            text.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
            text.SetBinding(TextBlock.TextProperty, new Binding("Title"));

            return(new DataTemplate {
                DataType = typeof(OmeaPluginsPageListEntry), VisualTree = stack
            });
        }
        private HierarchicalDataTemplate CreateTemplate(Type t)
        {
            string image;

            if (t == typeof(DatabaseExplorerServerViewModel))
            {
                image = "server";
            }
            else if (t == typeof(DatabaseExplorerDatabaseViewModel))
            {
                image = "database";
            }
            else
            {
                image = "table";
            }


            var dt = new HierarchicalDataTemplate(t);

            dt.ItemsSource = new Binding("Children");
            var f = new FrameworkElementFactory(typeof(StackPanel));

            f.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            var fi = new FrameworkElementFactory(typeof(Image));

            fi.SetValue(Image.SourceProperty,
                        new BitmapImage(new Uri(@"pack://application:,,,/MongoMS;component/View/" + image + ".png")));
            var ft = new FrameworkElementFactory(typeof(TextBlock));

            ft.SetBinding(TextBlock.TextProperty, new Binding("Name"));
            f.AppendChild(fi);
            f.AppendChild(ft);
            ContextMenu menu = GetMenu(t);

            f.SetValue(FrameworkElement.ContextMenuProperty, menu);
            var fcc = new FrameworkElementFactory(typeof(ContentControl));

            fcc.AddHandler(Control.MouseDoubleClickEvent, new MouseButtonEventHandler(tb_MouseUp));
            fcc.AppendChild(f);
            dt.VisualTree = fcc;
            return(dt);
        }
        private HierarchicalDataTemplate GenerateHierarchicalDataTemplateWithImage()
        {
            HierarchicalDataTemplate dataTemplate = new HierarchicalDataTemplate(typeof(ExplorerItem));

            string hierarchicalItemsSource = "Items";     // Explorer Items property
            string hierarchicalMemberPath  = "Header";    // Explorer Header property
            string hierarchicalImagePath   = "ImagePath"; // Explorer ImagePath property

            dataTemplate.ItemsSource = new Binding(hierarchicalItemsSource);

            FrameworkElementFactory frameworkElementFactory = new FrameworkElementFactory(typeof(Grid));

            var column1 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column1.SetValue(ColumnDefinition.WidthProperty, GridLength.Auto);

            var column2 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column2.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star));

            frameworkElementFactory.AppendChild(column1);
            frameworkElementFactory.AppendChild(column2);

            var image = new FrameworkElementFactory(typeof(Image));

            image.SetValue(Image.SourceProperty, new Binding(hierarchicalImagePath));
            image.SetValue(Image.MaxHeightProperty, 16.0);
            image.SetValue(Image.MaxWidthProperty, 16.0);
            image.SetValue(Image.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            image.SetValue(Image.MarginProperty, new Thickness(3, 0, 3, 0));

            var textBlock = new FrameworkElementFactory(typeof(TextBlock));

            textBlock.SetValue(TextBlock.TextProperty, new Binding(hierarchicalMemberPath));
            textBlock.SetValue(Grid.ColumnProperty, 1);

            frameworkElementFactory.AppendChild(image);
            frameworkElementFactory.AppendChild(textBlock);

            dataTemplate.VisualTree = frameworkElementFactory;

            return(dataTemplate);
        }
Exemplo n.º 13
0
        static MainWindow()
        {
            MimeMessage m; // DEBUG

            var spFactory = new FrameworkElementFactory(typeof(StackPanel));

            spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            var senderTbFactory = new FrameworkElementFactory(typeof(TextBlock));

            senderTbFactory.SetBinding(TextBlock.TextProperty, new Binding("From[0].Name"));
            spFactory.AppendChild(senderTbFactory);

            var sep1TbFactory = new FrameworkElementFactory(typeof(TextBlock));

            sep1TbFactory.SetValue(TextBlock.TextProperty, " -> ");
            spFactory.AppendChild(sep1TbFactory);

            var receiverTbFactory = new FrameworkElementFactory(typeof(TextBlock));

            receiverTbFactory.SetBinding(TextBlock.TextProperty, new Binding("To[0].Address"));
            spFactory.AppendChild(receiverTbFactory);

            var sep2TbFactory = new FrameworkElementFactory(typeof(TextBlock));

            sep2TbFactory.SetValue(TextBlock.TextProperty, " : ");
            spFactory.AppendChild(sep2TbFactory);

            var subjectTbFactory = new FrameworkElementFactory(typeof(TextBlock));

            subjectTbFactory.SetBinding(TextBlock.TextProperty, new Binding("Subject"));
            spFactory.AppendChild(subjectTbFactory);

            // TODO: установить триггер "прочитано-не прочитано"

            var sep3TbFactory = new FrameworkElementFactory(typeof(TextBlock));

            sep3TbFactory.SetValue(TextBlock.TextProperty, " (");
            spFactory.AppendChild(sep3TbFactory);

            var datetimeTbFactory = new FrameworkElementFactory(typeof(TextBlock));

            datetimeTbFactory.SetBinding(TextBlock.TextProperty, new Binding("Date"));
            spFactory.AppendChild(datetimeTbFactory);

            var sep4TbFactory = new FrameworkElementFactory(typeof(TextBlock));

            sep4TbFactory.SetValue(TextBlock.TextProperty, ")");
            spFactory.AppendChild(sep4TbFactory);

            letterDT            = new DataTemplate();
            letterDT.VisualTree = spFactory;
        }
Exemplo n.º 14
0
        private void AddItemFactory(FrameworkElementFactory parent, CityDataItem item)
        {
            var itemFactory = new FrameworkElementFactory(typeof(TextBlock));

            itemFactory.SetValue(TextBlock.TextProperty, item.Name.ToUpper());
            itemFactory.SetValue(TextBlock.FontSizeProperty, 13.0);
            itemFactory.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            itemFactory.SetValue(TextBlock.ForegroundProperty, new SolidColorBrush(Color.FromRgb(186, 28, 245)));
            parent.AppendChild(itemFactory);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 设置数据模板
        /// </summary>
        private void SetDataTemplate()
        {
            DataTemplate dt = new DataTemplate();

            FrameworkElementFactory fefStackPanel = new FrameworkElementFactory(typeof(StackPanel));

            fefStackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            Binding marginBinding = new Binding();

            marginBinding.Path = new PropertyPath("Margin");
            fefStackPanel.SetBinding(StackPanel.MarginProperty, marginBinding);


            FrameworkElementFactory fefToggleButton = new FrameworkElementFactory(typeof(ToggleButton));

            fefToggleButton.SetValue(ToggleButton.ClickModeProperty, ClickMode.Press);
            fefToggleButton.SetValue(ToggleButton.StyleProperty, Application.Current.Resources["ExpandCollapseToggleStyle"]);
            fefStackPanel.AppendChild(fefToggleButton);
            Binding isCheckedBinding = new Binding();

            isCheckedBinding.Path      = new PropertyPath("IsExpand");
            isCheckedBinding.Converter = new StringToBoolConvert();
            fefToggleButton.SetBinding(ToggleButton.IsCheckedProperty, isCheckedBinding);


            Binding visibilityBinding = new Binding();

            visibilityBinding.Path      = new PropertyPath("IsHaveChild");
            visibilityBinding.Converter = new BoolToVisibilityHidConverter();
            fefToggleButton.SetBinding(ToggleButton.VisibilityProperty, visibilityBinding);


            FrameworkElementFactory fefTextBlock = new FrameworkElementFactory(typeof(TextBlock));

            //Binding txtBinding = new Binding();
            //txtBinding.Path = new PropertyPath(BindingFiled);
            //fefTextBlock.SetBinding(TextBlock.TextProperty, txtBinding);
            fefStackPanel.AppendChild(fefTextBlock);
            _fefTextBlock = fefTextBlock;

            dt.VisualTree     = fefStackPanel;
            this.CellTemplate = dt;
        }
Exemplo n.º 16
0
        private void bigImgList()
        {
            DataTemplate            DT      = new DataTemplate();
            FrameworkElementFactory FEFMain = new FrameworkElementFactory(typeof(UniformGrid));

            FEFMain.SetValue(UniformGrid.WidthProperty, 100.00);
            FEFMain.SetValue(UniformGrid.HeightProperty, 100.00);
            FEFMain.SetValue(UniformGrid.RowsProperty, 2);
            FEFMain.SetValue(UniformGrid.ColumnsProperty, 1);

            FrameworkElementFactory FEFSecondRow = new FrameworkElementFactory(typeof(UniformGrid));

            FEFSecondRow.SetValue(UniformGrid.RowsProperty, 1);
            FEFSecondRow.SetValue(UniformGrid.ColumnsProperty, 2);

            FrameworkElementFactory FEFLabelName = new FrameworkElementFactory(typeof(Label));
            Binding bindLabelName = new Binding("Name");

            FEFLabelName.SetValue(ContentProperty, bindLabelName);

            FEFMain.AppendChild(FEFLabelName);
            FEFMain.AppendChild(FEFSecondRow);

            FrameworkElementFactory FEFLabelPrice = new FrameworkElementFactory(typeof(Label));
            Binding bindLabelPrice = new Binding("Price");

            FEFLabelPrice.SetValue(ContentProperty, bindLabelPrice);
            FEFSecondRow.AppendChild(FEFLabelPrice);

            DT.VisualTree = FEFMain;
            this.listView.ItemTemplate = DT;
            this.listView.View         = null;
            ItemsPanelTemplate      IPT           = new ItemsPanelTemplate();
            FrameworkElementFactory fefItemsPanel = new FrameworkElementFactory(typeof(WrapPanel));

            Binding bindWidth = new System.Windows.Data.Binding("ActualWidth");

            bindWidth.Source = this.listView;
            fefItemsPanel.SetValue(WrapPanel.WidthProperty, bindWidth);
            fefItemsPanel.SetValue(WrapPanel.OrientationProperty, Orientation.Horizontal);
            IPT.VisualTree           = fefItemsPanel;
            this.listView.ItemsPanel = IPT;
        }
Exemplo n.º 17
0
        private void AddTemperatureFactory(FrameworkElementFactory parent, double temp)
        {
            var tbFactory = new FrameworkElementFactory(typeof(TextBlock));

            tbFactory.SetValue(TextBlock.TextProperty, string.Format("{0}°F", temp.ToString("n0")));
            tbFactory.SetValue(TextBlock.FontSizeProperty, 16.0);
            tbFactory.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            tbFactory.SetValue(TextBlock.ForegroundProperty, new SolidColorBrush(Color.FromRgb(76, 76, 76)));
            parent.AppendChild(tbFactory);
        }
Exemplo n.º 18
0
        public BuildButtonFactory()
        {
            Title = "Build Button Factory";

            ControlTemplate template = new ControlTemplate(typeof(Button));

            FrameworkElementFactory factoryBorder = new FrameworkElementFactory(typeof(Border));

            factoryBorder.Name = "border";
            factoryBorder.SetValue(Border.BorderBrushProperty, Brushes.Red);
            factoryBorder.SetValue(Border.BorderThicknessProperty, new Thickness(3));
            factoryBorder.SetValue(Border.BackgroundProperty, SystemColors.ControlLightBrush);

            FrameworkElementFactory factoryContent = new FrameworkElementFactory(typeof(ContentPresenter));

            factoryContent.Name = "content";
            factoryContent.SetValue(ContentPresenter.ContentProperty,
                                    new TemplateBindingExtension(Button.ContentProperty));
            factoryContent.SetValue(ContentPresenter.MarginProperty,
                                    new TemplateBindingExtension(Button.PaddingProperty));

            factoryBorder.AppendChild(factoryContent);
            template.VisualTree = factoryBorder;

            Trigger trig = new Trigger();

            trig.Property = UIElement.IsMouseOverProperty;
            trig.Value    = true;

            Setter set = new Setter();

            set.Property   = Border.CornerRadiusProperty;
            set.Value      = new CornerRadius(24);
            set.TargetName = "border";
            trig.Setters.Add(set);

            set          = new Setter();
            set.Property = Control.FontStyleProperty;
            set.Value    = FontStyles.Italic;
            trig.Setters.Add(set);

            template.Triggers.Add(trig);

            Button btn = new Button();

            btn.Template            = template;
            btn.Content             = "Button with Custom Template";
            btn.Padding             = new Thickness(20);
            btn.FontSize            = 48;
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment   = VerticalAlignment.Center;
            btn.Click += ButtonOnClick;

            Content = btn;
        }
Exemplo n.º 19
0
        private ControlTemplate AlignLeftTemplate()
        {
            /*
             *  <ControlTemplate TargetType="{x:Type local:FlatMenuItemContainer}">
             *      <Grid>
             *          <Grid.ColumnDefinitions>
             *              <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemColumnGroupIcon"/>
             *              <ColumnDefinition Width="*"/> <!-- Main column -->
             *          </Grid.ColumnDefinitions>
             *
             *          <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header"/>
             *      </Grid>
             *  </ControlTemplate>
             */

            ControlTemplate template = new ControlTemplate(typeof(FlatMenuItemContainer));

            FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));

            FrameworkElementFactory column0 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column0.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Auto));
            column0.SetValue(DefinitionBase.SharedSizeGroupProperty, "MenuItemColumnGroupIcon");

            FrameworkElementFactory column1 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column1.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star));

            FrameworkElementFactory headerHost = new FrameworkElementFactory(typeof(ContentPresenter));

            headerHost.Name = "HeaderHost";
            headerHost.SetValue(ContentPresenter.ContentSourceProperty, "Header");
            headerHost.SetValue(Grid.ColumnProperty, 1);

            grid.AppendChild(column0);
            grid.AppendChild(column1);
            grid.AppendChild(headerHost);

            template.VisualTree = grid;

            return(template);
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var viewType = ViewLocator.LocateTypeForModelType(item.GetType(), null, null);

            if (viewType != null)
            {
                if (viewType.IsSubclassOf(typeof(BrowserExpander)) == true)
                {
                    var dataTemplate = new DataTemplate();
                    var element      = new FrameworkElementFactory(viewType);
                    element.SetBinding(BrowserExpander.HeaderProperty, new Binding("DisplayName"));
                    element.SetBinding(BrowserExpander.IsExpandedProperty, new Binding()
                    {
                        Path   = new PropertyPath(BrowserItemsControl.IsExpandedProperty),
                        Source = container,
                        Mode   = BindingMode.TwoWay,
                    });
                    element.SetBinding(Bind.ModelProperty, new Binding());
                    element.AddHandler(BrowserExpander.ExpandedEvent, new RoutedEventHandler(BrowserExpander_RoutedEventHandler));
                    element.AddHandler(BrowserExpander.CollapsedEvent, new RoutedEventHandler(BrowserExpander_RoutedEventHandler));
                    dataTemplate.VisualTree = element;
                    return(dataTemplate);
                }
                else
                {
                    var dataTemplate = new DataTemplate();
                    var element      = new FrameworkElementFactory(typeof(BrowserExpander));
                    element.SetBinding(BrowserExpander.HeaderProperty, new Binding("DisplayName"));
                    element.SetBinding(BrowserExpander.IsExpandedProperty, new Binding()
                    {
                        Path   = new PropertyPath(BrowserItemsControl.IsExpandedProperty),
                        Source = container,
                        Mode   = BindingMode.TwoWay,
                    });
                    element.AddHandler(BrowserExpander.ExpandedEvent, new RoutedEventHandler(BrowserExpander_RoutedEventHandler));
                    element.AddHandler(BrowserExpander.CollapsedEvent, new RoutedEventHandler(BrowserExpander_RoutedEventHandler));
                    var contentElement = new FrameworkElementFactory(viewType);
                    contentElement.SetBinding(Bind.ModelProperty, new Binding());
                    element.AppendChild(contentElement);
                    dataTemplate.VisualTree = element;
                    return(dataTemplate);
                }
            }

            return(base.SelectTemplate(item, container));

            void BrowserExpander_RoutedEventHandler(object sender, RoutedEventArgs e)
            {
                if (sender is BrowserExpander expander)
                {
                    BrowserItemsControl.SetIsExpanded(container, expander.IsExpanded);
                }
            }
        }
Exemplo n.º 21
0
        public override FrameworkElementFactory Apply(BorderExtensionDescription fieldExtensionDescription, FrameworkElementFactory frameworkElementFactory)
        {
            FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border));

            border.SetValue(Border.BorderBrushProperty, new SolidColorBrush(fieldExtensionDescription.Color));
            border.SetValue(Border.BorderThicknessProperty, new Thickness(2));

            border.AppendChild(frameworkElementFactory);

            return(border);
        }
Exemplo n.º 22
0
        internal override FrameworkElementFactory GetFactory()
        {
            FrameworkElementFactory elementFactory = base.GetFactory();

            foreach (var child in this.children.OfType <FluentTemplateItem>())
            {
                elementFactory.AppendChild(child.GetFactory());
            }

            return(elementFactory);
        }
        private Style CreateBaseButtonStyle()
        {
            var style    = new Style();
            var template = new ControlTemplate(typeof(ActionButton));
            var factory  = new FrameworkElementFactory(typeof(Border));

            factory.SetBinding(Border.BackgroundProperty, new Binding {
                RelativeSource = RelativeSource.TemplatedParent, Path = new PropertyPath("Background")
            });
            factory.SetBinding(Border.PaddingProperty, new Binding {
                RelativeSource = RelativeSource.TemplatedParent, Path = new PropertyPath("Padding")
            });
            template.VisualTree = factory;
            factory.AppendChild(new FrameworkElementFactory(typeof(ContentPresenter)));
            style.Setters.Add(new Setter {
                Property = ActionButton.TemplateProperty, Value = template
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.SnapsToDevicePixelsProperty, Value = true
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.PaddingProperty, Value = new Thickness(12, 4, 12, 4)
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.VerticalContentAlignmentProperty, Value = VerticalAlignment.Center
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.HorizontalContentAlignmentProperty, Value = HorizontalAlignment.Center
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.ForegroundProperty, Value = new SolidColorBrush(Color.FromRgb(255, 255, 255))
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.FontFamilyProperty, Value = SystemFonts.MessageFontFamily
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.FontSizeProperty, Value = 14.0
            });
            style.Setters.Add(new Setter {
                Property = ActionButton.FontWeightProperty, Value = FontWeight.FromOpenTypeWeight(700)
            });

            // Fade the button if it's disabled.
            var trigger = new Trigger {
                Property = ActionButton.IsEnabledProperty, Value = false
            };

            trigger.Setters.Add(new Setter {
                Property = ActionButton.OpacityProperty, Value = 0.5
            });
            style.Triggers.Add(trigger);

            return(style);
        }
Exemplo n.º 24
0
        internal static FrameworkElementFactory CreateBoundColumnTemplate(ApplicationContext ctx, WidgetBackend parent, CellViewCollection views, string dataPath = ".")
        {
            if (views.Count == 1)
            {
                return(CreateBoundCellRenderer(ctx, parent, views[0], dataPath));
            }

            FrameworkElementFactory container = new FrameworkElementFactory(typeof(Grid));

            int i = 0;

            foreach (CellView view in views)
            {
                var factory = CreateBoundCellRenderer(ctx, parent, view, dataPath);

                factory.SetValue(FrameworkElement.MarginProperty, CellMargins);

                if (view.VisibleField != null)
                {
                    var binding = new Binding(dataPath + "[" + view.VisibleField.Index + "]");
                    binding.Converter = new BooleanToVisibilityConverter();
                    factory.SetBinding(UIElement.VisibilityProperty, binding);
                }
                else if (!view.Visible)
                {
                    factory.SetValue(UIElement.VisibilityProperty, Visibility.Collapsed);
                }

                factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, view.Expands ? HorizontalAlignment.Stretch : HorizontalAlignment.Left);
                factory.SetValue(Grid.ColumnProperty, i);
                var column = new FrameworkElementFactory(typeof(ColumnDefinition));
                column.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, view.Expands ? GridUnitType.Star : GridUnitType.Auto));

                container.AppendChild(column);
                container.AppendChild(factory);

                i++;
            }

            return(container);
        }
Exemplo n.º 25
0
        //public TempDataType CreateTempDataType(string e_strName, int e_iStartTime, int e_iEndTime)
        //{
        //    var temp = new TempDataType()
        //    {
        //        StartTime = e_iStartTime,
        //        EndTime = e_iEndTime,
        //        Name = e_strName
        //    };
        //    return temp;
        //}
        #endregion
        #region CreateDataTemplate
        DataTemplate CreateDataTemplate()
        {
            //http://stackoverflow.com/questions/248362/how-do-i-build-a-datatemplate-in-c-sharp-code
            //create the data template
            DataTemplate cardLayout = new DataTemplate();
            //cardLayout.DataType = typeof(CreditCardPayment);

            //set up the stack panel
            FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel));

            spFactory.Name = "myComboFactory";
            spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            //set up the card holder textblock
            FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(TextBlock));

            cardHolder.SetBinding(TextBlock.TextProperty, new Binding("BillToName"));
            cardHolder.SetValue(TextBlock.ToolTipProperty, "Card Holder Name");
            spFactory.AppendChild(cardHolder);

            //set up the card number textblock
            FrameworkElementFactory cardNumber = new FrameworkElementFactory(typeof(TextBlock));

            cardNumber.SetBinding(TextBlock.TextProperty, new Binding("SafeNumber"));
            cardNumber.SetValue(TextBlock.ToolTipProperty, "Credit Card Number");
            spFactory.AppendChild(cardNumber);

            //set up the notes textblock
            FrameworkElementFactory notes = new FrameworkElementFactory(typeof(TextBlock));

            notes.SetBinding(TextBlock.TextProperty, new Binding("Notes"));
            notes.SetValue(TextBlock.ToolTipProperty, "Notes");
            spFactory.AppendChild(notes);

            //set the visual tree of the data template
            cardLayout.VisualTree = spFactory;

            //set the item template to be our shiny new data template
            //drpCreditCardNumberWpf.ItemTemplate = cardLayout;
            return(cardLayout);
        }
Exemplo n.º 26
0
        internal void PopulateFamiliesComboBox()
        {
            if (ONBOXApplication.storedBeamFamilesInfo.Count > 0)
            {
                //if we have beams in the project enable the combofamily and the create button
                comboFamily.IsEnabled = true;
                btnCreate.IsEnabled   = true;

                comboFamily.ItemsSource = ONBOXApplication.storedBeamFamilesInfo;

                DataTemplate dFamiliesTemplate = new DataTemplate();
                dFamiliesTemplate.DataType = typeof(FamilyWithImage);

                FrameworkElementFactory fTemplate = new FrameworkElementFactory(typeof(StackPanel));
                fTemplate.Name = "myComboFactory";
                fTemplate.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

                FrameworkElementFactory fImage = new FrameworkElementFactory(typeof(Image));
                fImage.SetBinding(Image.SourceProperty, new Binding("Image"));
                fTemplate.AppendChild(fImage);

                FrameworkElementFactory fText1 = new FrameworkElementFactory(typeof(Label));
                fText1.SetBinding(Label.ContentProperty, new Binding("FamilyName"));
                fText1.SetValue(Label.HorizontalAlignmentProperty, System.Windows.HorizontalAlignment.Center);
                fText1.SetValue(Label.VerticalAlignmentProperty, System.Windows.VerticalAlignment.Center);
                fTemplate.AppendChild(fText1);

                dFamiliesTemplate.VisualTree = fTemplate;
                comboFamily.ItemTemplate     = dFamiliesTemplate;
                if (comboFamily.HasItems)
                {
                    comboFamily.SelectedIndex = 0;
                }
            }
            else
            {
                //if we dont have beams in the project disable the combofamily and the create button
                comboFamily.IsEnabled = false;
                btnCreate.IsEnabled   = false;
            }
        }
Exemplo n.º 27
0
        public static ControlTemplate CreateTemplate(string key, IEnumerable <Connector> connectors)
        {
            var enumerable = connectors as IList <Connector> ?? connectors.ToList();

            var outputs = (from con in enumerable
                           where (con.Type == Direction.OUT || con.Type == Direction.INOUT)
                           select con).ToList();

            var inputs = (from con in enumerable
                          where !outputs.Contains(con)
                          select con).ToList();

            //Create the control template
            var controlTemplate = new ControlTemplate();

            controlTemplate.TargetType = typeof(Control);

            // set up wrapping stackpanel
            var layout = new FrameworkElementFactory(typeof(RelativePositionPanel));

            for (int i = 0; i < inputs.Count; i++)
            {
                double height          = (1.0 / (inputs.Count + 1)) * (i + 1);
                var    inputConnection = new FrameworkElementFactory(typeof(ConnectorViewModel));
                inputConnection.SetValue(ConnectorViewModel.OrientationProperty, ConnectorOrientation.Left);
                inputConnection.SetValue(RelativePositionPanel.RelativePositionProperty, new Point(0, height));
                inputConnection.SetValue(ConnectorViewModel.ConnectorProperty, inputs[i]);
                layout.AppendChild(inputConnection);
            }
            for (var i = 0; i < outputs.Count; i++)
            {
                double height           = (1.0 / (outputs.Count + 1)) * (i + 1);
                var    outputConnection = new FrameworkElementFactory(typeof(ConnectorViewModel));
                outputConnection.SetValue(ConnectorViewModel.OrientationProperty, ConnectorOrientation.Right);
                outputConnection.SetValue(RelativePositionPanel.RelativePositionProperty, new Point(1, height));
                outputConnection.SetValue(ConnectorViewModel.ConnectorProperty, outputs[i]);
                layout.AppendChild(outputConnection);
            }
            controlTemplate.VisualTree = layout;
            return(controlTemplate);
        }
        private static ControlTemplate GetIconTemplate()
        {
            var template = new ControlTemplate(typeof(PackIconOcticonsControl));

            var root = new FrameworkElementFactory(typeof(Grid));

            var border = new FrameworkElementFactory(typeof(Border));

            border.SetValue(Control.BackgroundProperty, new TemplateBindingExtension(Control.BackgroundProperty));
            border.SetValue(Control.BorderBrushProperty, new TemplateBindingExtension(Control.BorderBrushProperty));
            border.SetValue(Control.BorderThicknessProperty, new TemplateBindingExtension(Control.BorderThicknessProperty));
            border.SetValue(Control.SnapsToDevicePixelsProperty, new TemplateBindingExtension(Control.SnapsToDevicePixelsProperty));
            root.AppendChild(border);

            var innerGrid = new FrameworkElementFactory(typeof(Grid));

            innerGrid.SetValue(FrameworkElement.MarginProperty, new TemplateBindingExtension(Control.BorderThicknessProperty));

            var path = new FrameworkElementFactory(typeof(Path));

            path.SetValue(Path.FillProperty, new TemplateBindingExtension(Control.ForegroundProperty));
            path.SetValue(Path.StretchProperty, Stretch.Uniform);
            path.SetBinding(Path.DataProperty, new Binding(nameof(PackIconOcticonsControl.Data))
            {
                RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent), Mode = BindingMode.OneWay
            });
            path.SetValue(UIElement.SnapsToDevicePixelsProperty, false);
            path.SetValue(FrameworkElement.UseLayoutRoundingProperty, false);

            var viewBox = new FrameworkElementFactory(typeof(Viewbox));

            viewBox.SetValue(FrameworkElement.MarginProperty, new TemplateBindingExtension(Control.PaddingProperty));

            viewBox.AppendChild(path);
            innerGrid.AppendChild(viewBox);
            root.AppendChild(innerGrid);

            template.VisualTree = root;
            template.Seal();
            return(template);
        }
Exemplo n.º 29
0
        private void SetCellVerticalAlignment(object value)
        {
            _CellStyleFEF = new FrameworkElementFactory(typeof(TextBlock));
            _CellStyleFEF.SetValue(TextBlock.HorizontalAlignmentProperty, _CellHorizontalAlignment);
            _CellStyleFEF.SetValue(TextBlock.VerticalAlignmentProperty, value);
            _CellStyleFEF.SetValue(TextBlock.TextWrappingProperty, TextWrapping.Wrap);
            _CellStyleFEF.AppendChild(new FrameworkElementFactory(typeof(ContentPresenter)));
            ControlTemplate cellTemplate = new ControlTemplate(typeof(DataGridCell));

            cellTemplate.VisualTree = _CellStyleFEF;
            _CellStyle.Setters.Add(new Setter(DataGridCell.TemplateProperty, cellTemplate));
        }
Exemplo n.º 30
0
        /// <summary>
        /// </summary>
        /// <param name="image"> </param>
        /// <param name="name"> </param>
        /// <returns> </returns>
        public static DataTemplate ImageHeader(BitmapImage image, string name)
        {
            var dataTemplate      = new DataTemplate();
            var stackPanelFactory = new FrameworkElementFactory(typeof(StackPanel));
            var imageFactory      = new FrameworkElementFactory(typeof(Image));
            var labelFactory      = new FrameworkElementFactory(typeof(Label));

            imageFactory.SetValue(FrameworkElement.HeightProperty, (double)24);
            imageFactory.SetValue(FrameworkElement.WidthProperty, (double)24);
            imageFactory.SetValue(FrameworkElement.ToolTipProperty, name);
            imageFactory.SetValue(Image.SourceProperty, image);
            var binding = BindingHelper.VisibilityBinding(Settings.Default, "EnableHelpLabels");

            labelFactory.SetBinding(UIElement.VisibilityProperty, binding);
            labelFactory.SetValue(ContentControl.ContentProperty, name);
            stackPanelFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            stackPanelFactory.AppendChild(imageFactory);
            stackPanelFactory.AppendChild(labelFactory);
            dataTemplate.VisualTree = stackPanelFactory;
            return(dataTemplate);
        }