private DataTemplate CreateItemTemplate()
        {
            var template = new DataTemplate();

            template.VisualTree = new FrameworkElementFactory(typeof(StackPanel));

            var txtBlock = new FrameworkElementFactory(typeof(TextBlock));
            txtBlock.SetBinding(TextBlock.TextProperty, new Binding("Street1")); 
            template.VisualTree.AppendChild(txtBlock);

            txtBlock = new FrameworkElementFactory(typeof(TextBlock));
            txtBlock.SetBinding(TextBlock.TextProperty, new Binding("City")); 
            template.VisualTree.AppendChild(txtBlock);

            var trigger = new MultiDataTrigger();

            trigger.Conditions.Add(
                new Condition(
                    new Binding("Cty"), //misspelling
                    "Tallahassee"
                    )
                );

            trigger.Conditions.Add(
                new Condition(
                    new Binding("StateOrProvince"),
                    "Florida"
                    )
                );

            template.Triggers.Add(trigger);

            return template;
        }
		public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource)
		{
			var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock));
			var binding = new sw.Data.Binding { Path = TextPath, RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged };
			factory.SetBinding(EditableTextBlock.TextProperty, binding);
			return factory;
		}
        private void ShowResourcesGained_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            RollDiceAction rollDice = e.NewValue as RollDiceAction;
            Dictionary<GamePlayer, ResourceList> result = rollDice.PlayersResources;

            basePanel.Children.Clear();

            foreach (KeyValuePair<GamePlayer, ResourceList> kvp in result)
            {
                // add list of resources
                ItemsControl resources = new ItemsControl();

                FrameworkElementFactory stackPanelElement = new FrameworkElementFactory(typeof(StackPanel));
                stackPanelElement.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
                resources.ItemsPanel = new ItemsPanelTemplate() { VisualTree = stackPanelElement};
                resources.Height = 90;

                Binding binding = new Binding()
                {
                    Converter = new ResourceConverter()
                };
                FrameworkElementFactory imageElement = new FrameworkElementFactory(typeof(Image));
                imageElement.SetBinding(Image.SourceProperty, binding);
                imageElement.SetValue(Image.HeightProperty, 80.0);
                imageElement.SetValue(Image.WidthProperty, 80.0);

                resources.ItemTemplate = new DataTemplate()
                {
                    VisualTree = imageElement
                };
                basePanel.Children.Add(resources);
                resources.ItemsSource = kvp.Value;
            }
        }
Beispiel #4
0
        internal static FrameworkElementFactory CreateBoundCellRenderer(CellView view, string dataPath = ".")
        {
            TextCellView textView = view as TextCellView;
            if (textView != null) {
                FrameworkElementFactory factory = new FrameworkElementFactory (typeof (SWC.TextBlock));
                factory.SetValue (FrameworkElement.MarginProperty, CellMargins);

                if (textView.TextField != null)
                    factory.SetBinding (SWC.TextBlock.TextProperty, new Binding (dataPath + "[" + textView.TextField.Index + "]"));

                return factory;
            }

            ImageCellView imageView = view as ImageCellView;
            if (imageView != null) {
                FrameworkElementFactory factory = new FrameworkElementFactory (typeof (ImageBox));
                factory.SetValue (FrameworkElement.MarginProperty, CellMargins);

                if (imageView.ImageField != null) {
                    var binding = new Binding (dataPath + "[" + imageView.ImageField.Index + "]")
                    { Converter = new ImageToImageSourceConverter () };

                    factory.SetBinding (ImageBox.ImageSourceProperty, binding);
                }

                return factory;
            }

            throw new NotImplementedException ();
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var rule = item as RuleViewModel;
            if (rule == null)
                return null;

            FrameworkElementFactory checkBoxFactory = new FrameworkElementFactory(typeof(CheckBox));
            Binding isCheckedBinding = new Binding("IsSelected")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            checkBoxFactory.SetBinding(CheckBox.IsCheckedProperty, isCheckedBinding);

            FrameworkElementFactory textBlockFactory = new FrameworkElementFactory(typeof(TextBlock));
            textBlockFactory.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            textBlockFactory.SetValue(TextBlock.TextProperty, (rule.Index + 1).ToString());
            textBlockFactory.SetValue(TextBlock.MarginProperty, new Thickness(0, 5, 0, 0));

            FrameworkElementFactory stackPanelFactory = new FrameworkElementFactory(typeof(StackPanel));
            stackPanelFactory.AppendChild(checkBoxFactory);
            stackPanelFactory.AppendChild(textBlockFactory);

            return new DataTemplate { VisualTree = stackPanelFactory };
        }
Beispiel #6
0
        private static void OnLogSourceChanged(DependencyObject d,
            DependencyPropertyChangedEventArgs e)
        {
            ListView listView = d as ListView;
            LogItemCollection collection = e.NewValue as LogItemCollection;

            listView.ItemsSource = collection;
            GridView gridView = listView.View as GridView;
            int count = 0;
            gridView.Columns.Clear();
            foreach (var col in collection.Columns)
            {
                var cell = new FrameworkElementFactory(typeof(TextBlock));
                cell.SetBinding(TextBlock.TextProperty, new Binding(string.Format("[{0}]", count++)));
                cell.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 4, 0, 4));

                gridView.Columns.Add(
                    new GridViewColumn
                    {
                        Header = new TextBlock { Text = col, FontSize = 11, Margin = new Thickness(5, 4, 5, 4) },
                        CellTemplate = new DataTemplate
                        {
                            DataType = typeof(LogItemCollection),
                            VisualTree = cell,
                        }
                    });
            }
        }
        public FrameworkElementFactory CreateOnOffServiceScheduleButtonTemplate()
        {
            FrameworkElementFactory buttonTemplate = new FrameworkElementFactory(typeof (CheckBox));
            buttonTemplate.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsOn")
            {
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            });

            buttonTemplate.AddHandler(
                ToggleButton.CheckedEvent,
                new RoutedEventHandler((o, e) =>
                {
                    DataGridServiceScheduleView dataGridServiceScheduleView =
                        ((FrameworkElement) o).DataContext as DataGridServiceScheduleView;
                    if (dataGridServiceScheduleView != null)
                    {
                        dataGridServiceScheduleView.IsOn = true.ToString();
                    }
                }));
            buttonTemplate.AddHandler(
                ToggleButton.UncheckedEvent,
                new RoutedEventHandler((o, e) =>
                {
                    DataGridServiceScheduleView dataGridServiceScheduleView =
                        ((FrameworkElement) o).DataContext as DataGridServiceScheduleView;
                    if (dataGridServiceScheduleView != null)
                    {
                        dataGridServiceScheduleView.IsOn = false.ToString();
                    }
                }));
            return buttonTemplate;
        }
Beispiel #8
0
        public HierarchyControl()
        {
            RecursiveSelectedItems = new ObservableCollection<object>();

            //set items panel
            FrameworkElementFactory factoryPanel = new FrameworkElementFactory(typeof(StackPanel));
            factoryPanel.SetValue(StackPanel.IsItemsHostProperty, true);
            ItemsPanelTemplate template = new ItemsPanelTemplate();
            template.VisualTree = factoryPanel;
            ItemsPanel = template;

            //bind parent
            Binding parentBind = new Binding();
            parentBind.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(HierarchyControl), 1);
            this.SetBinding(ParentHierarchyProperty, parentBind);

            FrameworkElementFactory factoryItem = new FrameworkElementFactory(typeof(HierarchyControl));
            var item_template = new DataTemplate();
            item_template.VisualTree = factoryItem;
            ItemTemplate = item_template;

            //bind intermediate children to items source
            //this.SetBinding(ItemsSourceProperty, new Binding("Children"));

            //drag and drop binds
            this.Loaded += HierarchyControl_Loaded;
            this.Unloaded += HierarchyControl_Unloaded;
            this.GiveFeedback += DragController.Drag_GiveFeedback;

            Binding bind_int = new Binding("IntermediateSource");
            bind_int.RelativeSource = new RelativeSource(RelativeSourceMode.Self);
            this.SetBinding(HierarchyControl.ItemsSourceProperty, bind_int);
            IntermediateSource.CollectionChanged += IntermediateSource_CollectionChanged;
        }
 internal static DataTemplate CreateDefaultTemplate()
 {
     var dataTemplate = new DataTemplate();
     var factory = new FrameworkElementFactory(typeof(ContentPresenter));
     dataTemplate.VisualTree = factory;
     return dataTemplate;
 }
        private void KernelOnComponentRegistered(string key, IHandler handler)
        {
            Type implementation = handler.ComponentModel.Implementation;
            if (implementation.Namespace == null ||
                !implementation.Namespace.EndsWith("ViewModels"))
            {
                return;
            }

            var viewTypeName = implementation.Namespace.Replace("ViewModels", "Views") + "." +
                                implementation.Name.Replace("ViewModel", "View");

            var qualifiedViewTypeName = implementation.AssemblyQualifiedName.Replace(implementation.FullName, viewTypeName);

            Type viewType = Type.GetType(qualifiedViewTypeName, false);
            if (viewType == null)
            {
                throw new InvalidOperationException();
            }

            var dt = new DataTemplate {DataType = viewType};

            var viewFactory = new FrameworkElementFactory(viewType);
            dt.VisualTree = viewFactory;

            _resources.Add(new DataTemplateKey(implementation), dt);
        }
        public TextureManager()
        {
            InitializeComponent();

            DataGridTemplateColumn col = new DataGridTemplateColumn();
            Binding imgBinding = new Binding("Name") { Converter = new Controls.PathToImageConverter() };
            FrameworkElementFactory imgFactory = new FrameworkElementFactory(typeof(Image));
            imgFactory.SetBinding(Image.SourceProperty, imgBinding);
            imgFactory.SetValue(Image.MaxHeightProperty, 64.0);
            imgFactory.SetValue(Image.MaxWidthProperty, 64.0);
            imgFactory.SetValue(Image.TagProperty, "PreviewImage");
            ((DataGridTemplateColumn)col).CellTemplate = new DataTemplate();
            ((DataGridTemplateColumn)col).CellTemplate.VisualTree = imgFactory;
            col.Header = "Preview";
            gridView.Columns.Add(col);

            formStack.Children.Add(textureForm_ = new ReflectiveForm(typeof(Urho.Texture)));
            texTree.DataContext = Project.inst().Textures;
            texTree.SelectedItemChanged += texTree_SelectedItemChanged;
            gridView.DataContext = flat_ = Project.inst().Textures.GetFlat();

            formStack.Children.Add(nothing_ = new NothingHere("Texture"));
            nothing_.Visibility = System.Windows.Visibility.Visible;
            textureForm_.Visibility = System.Windows.Visibility.Collapsed;
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var template = value as Xamarin.Forms.DataTemplate;
            var uc = new FrameworkElementFactory(typeof(UserControl));
            if (template != null)
            {
                uc.SetBinding(UserControl.ContentProperty, new MultiBinding
                {
                    Converter = new CellToViewConverter(),
                    Bindings =
                    {
                        new Binding(),
                        new Binding { Source = template }
                    }
                });
            }
            else
            {
                uc.SetBinding(UserControl.ContentProperty, new Binding
                {
                    Converter = new ModelToViewConverter()
                });
            }

            return new DataTemplate { VisualTree = uc };
        }
 public DataTemplate CreateByViewType(Type viewModelType, Type viewType)
 {
     var dt = new DataTemplate(viewModelType);
     var factory = new FrameworkElementFactory(viewType);
     dt.VisualTree = factory;
     return dt;
 }
		void ChangeIsDeleted()
		{
			if (_deletationType == LogicalDeletationType.All)
			{
				if (!IsColumnShown)
				{
					var gridViewColumn = new GridViewColumn();
					gridViewColumn.Header = "Дата удаления";
					gridViewColumn.Width = 150;
					var dataTemplate = new DataTemplate();
					var txtElement = new FrameworkElementFactory(typeof(IsDeletedTextBlock));
					dataTemplate.VisualTree = txtElement;
					var binding = new Binding();
					var bindingPath = string.Format("RemovalDate");
					binding.Path = new PropertyPath(bindingPath);
					binding.Mode = BindingMode.OneWay;
					txtElement.SetBinding(IsDeletedTextBlock.TextProperty, binding);
					gridViewColumn.CellTemplate = dataTemplate;
					ListViewLayoutManager.SetCanUserResize(gridViewColumn, false);
					gridView.Columns.Add(gridViewColumn);
				}
			}
			else if (IsColumnShown)
			{
				gridView.Columns.Remove(IsDeletedColumn);
			}
		}
        public MainWindowViewModel()
        {
            SampleData.Seed();

            // create accent color menu items for the demo
            this.AccentColors = ThemeManager.Accents
                                            .Select(a => new AccentColorMenuData() { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush })
                                            .ToList();

            // create metro theme color menu items for the demo
            this.AppThemes = ThemeManager.AppThemes
                                           .Select(a => new AppThemeMenuData() { Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush })
                                           .ToList();
            

            Albums = SampleData.Albums;
            Artists = SampleData.Artists;

            FlipViewTemplateSelector = new RandomDataTemplateSelector();

            FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(Image));
            spFactory.SetBinding(Image.SourceProperty, new System.Windows.Data.Binding("."));
            spFactory.SetValue(Image.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
            spFactory.SetValue(Image.StretchProperty, Stretch.Fill);
            FlipViewTemplateSelector.TemplateOne = new DataTemplate()
            {
                VisualTree = spFactory
            };
            FlipViewImages = new string[] { "http://trinities.org/blog/wp-content/uploads/red-ball.jpg", "http://savingwithsisters.files.wordpress.com/2012/05/ball.gif" };

            RaisePropertyChanged("FlipViewTemplateSelector");


            BrushResources = FindBrushResources();
        }
        public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            var datatemplate = new DataTemplate();
            if (item == null)
                return datatemplate;
            if (_edit)
            {
                datatemplate.VisualTree = new FrameworkElementFactory(typeof(StackPanel));
                var converter = new EnumValueConverter(item,property);
                foreach (object value in Enum.GetValues(enumType))
                {
                    var cbox = new FrameworkElementFactory(typeof(CheckBox));
                    cbox.SetValue(CheckBox.ContentProperty, value.ToString());
                    Delegate add = (RoutedEventHandler)delegate(object obj, RoutedEventArgs e) { };
                    var b = new Binding(property);
                    b.Converter = converter;
                    b.ConverterParameter = value;
                    b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                    cbox.SetValue(CheckBox.IsCheckedProperty, b);
                    cbox.AddHandler(CheckBox.CheckedEvent, add);
                    cbox.AddHandler(CheckBox.UncheckedEvent, add);
                    datatemplate.VisualTree.AppendChild(cbox);
                }
            }
            else
            {
                datatemplate.VisualTree = new FrameworkElementFactory(typeof(Label));
                datatemplate.VisualTree.SetValue(Label.ContentProperty, new Binding(property));
            }

            return datatemplate;
        }
Beispiel #17
0
        private static DataTemplate CreateTemplate()
        {
            DataTemplate template = new DataTemplate {DataType = typeof(UiDataProviderNode)};

            FrameworkElementFactory stackPanel = new FrameworkElementFactory(typeof(StackPanel));
            stackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            FrameworkElementFactory image = new FrameworkElementFactory(typeof(Image));
            image.SetValue(HeightProperty, 16d);
            image.SetValue(Image.SourceProperty, new Binding("Icon"));
            image.SetValue(MarginProperty, new Thickness(3));
            stackPanel.AppendChild(image);

            //FrameworkElementFactory icon = new FrameworkElementFactory(typeof(ContentPresenter));
            //icon.SetValue(HeightProperty, 16d);
            //icon.SetValue(ContentPresenter.ContentProperty, new Binding("Icon"));
            //icon.SetValue(MarginProperty, new Thickness(3));
            //stackPanel.AppendChild(icon);

            FrameworkElementFactory textBlock = new FrameworkElementFactory(typeof(TextBlock));
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("Title"));
            textBlock.SetBinding(ToolTipProperty, new Binding("Description"));
            textBlock.SetValue(MarginProperty, new Thickness(3));
            stackPanel.AppendChild(textBlock);

            template.VisualTree = stackPanel;

            return template;
        }
 internal static DataTemplate CreateFallbackViewTemplate(string errorText) {
     var factory = new FrameworkElementFactory(typeof(FallbackView));
     factory.SetValue(FallbackView.TextProperty, errorText);
     var res = new DataTemplate() { VisualTree = factory };
     res.Seal();
     return res;
 }
        public SelectFolderDesigner()
        {
            this.InlineEditorTemplate = new DataTemplate();

            var stack = new FrameworkElementFactory(typeof(DockPanel));
            stack.SetValue(DockPanel.LastChildFillProperty, true);

            var editModeSwitch = new FrameworkElementFactory(typeof(EditModeSwitchButton));

            editModeSwitch.SetValue(EditModeSwitchButton.TargetEditModeProperty, PropertyContainerEditMode.Dialog);
            editModeSwitch.SetValue(DockPanel.DockProperty, Dock.Right);

            stack.AppendChild(editModeSwitch);

            // Erstellen und Konfiguration des Labels
            var label = new FrameworkElementFactory(typeof(Label));
            //Binding labelBinding = new Binding("Value");

            // Setzen der Eigenschaften des Labels
            label.SetValue(ContentControl.ContentProperty, "Bitte den Dialog öffnen");
            label.SetValue(DockPanel.DockProperty, Dock.Left);

            stack.AppendChild(label);

            this.InlineEditorTemplate.VisualTree = stack;

            // Zuordnen des DataTemplates
            // this.InlineEditorTemplate = res["SelectFileEditorTemplate"] as DataTemplate;
        }
        internal static System.Windows.DataTemplate CreateCellTemplate(EntityFieldInfo entityFieldInfo,DataGrid dataGrid)
        {
            DataTemplate dataTemplate = new DataTemplate();
            FrameworkElementFactory contentControl = new FrameworkElementFactory(typeof(ContentControl));
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
            Style contentControlStyle = new Style();
            contentControl.SetValue(ContentControl.StyleProperty, contentControlStyle);

            DataTemplate tpl = new DataTemplate();
            if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Color)
            {
                FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
                Binding binding = CreateBindingOneWay(entityFieldInfo.Path);
                binding.Converter = new StringToBrushConverter();
                grid.SetBinding(Grid.BackgroundProperty, binding);
                tpl.VisualTree = grid;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }
            else
            {
                FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBlock));
                if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Pr)
                { textBox.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right); }
                textBox.SetBinding(TextBlock.TextProperty, CreateBindingOneWay(entityFieldInfo.Path));
                tpl.VisualTree = textBox;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }

            return dataTemplate;
        }
Beispiel #21
0
		void UpdateAdditionalColumns()
		{
			GridView gridView = _treeList.View as GridView;
			EmployeesViewModel employeesViewModel = _treeList.DataContext as EmployeesViewModel;
			if (employeesViewModel.AdditionalColumnNames == null)
				return;

			var columnCount = 2;
			for (int i = gridView.Columns.Count - 1; i >= columnCount; i--)
			{
				gridView.Columns.RemoveAt(i);
			}

			for (int i = 0; i < employeesViewModel.AdditionalColumnNames.Count; i++)
			{
				var gridViewColumn = new GridViewColumn();
				gridViewColumn.Header = employeesViewModel.AdditionalColumnNames[i];
				gridViewColumn.Width = 350;

				var dataTemplate = new DataTemplate();
				var txtElement = new FrameworkElementFactory(typeof(TextBlock));
				dataTemplate.VisualTree = txtElement;
				var binding = new Binding();
				var bindingPath = string.Format("AdditionalColumnValues[{0}]", i);
				binding.Path = new PropertyPath(bindingPath);
				binding.Mode = BindingMode.OneWay;
				txtElement.SetBinding(TextBlock.TextProperty, binding);
				ListViewLayoutManager.SetStarWidth(gridViewColumn, 5);
				gridViewColumn.CellTemplate = dataTemplate;
				gridView.Columns.Add(gridViewColumn);
			}
		}
Beispiel #22
0
        //private static readonly DataTemplate DefaultTemplate;
        static ComboBoxBackend()
        {
            if (System.Windows.Application.Current.Resources.MergedDictionaries.Count == 0 ||
                !System.Windows.Application.Current.Resources.MergedDictionaries.Any(x => x.Contains(typeof(ExComboBox))))
            {
                var factory = new FrameworkElementFactory(typeof(WindowsSeparator));
                factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);

                var sepTemplate = new ControlTemplate(typeof(ComboBoxItem));
                sepTemplate.VisualTree = factory;

                DataTrigger trigger = new DataTrigger();
                trigger.Binding = new Binding(".[1]") { Converter = new TypeToStringConverter() };
                trigger.Value = typeof(ItemSeparator).Name;
                trigger.Setters.Add(new Setter(Control.TemplateProperty, sepTemplate));
                trigger.Setters.Add(new Setter(UIElement.IsEnabledProperty, false));

                ContainerStyle = new Style(typeof(ComboBoxItem));
                ContainerStyle.Triggers.Add(trigger);
            }
            else
            {
                ContainerStyle = null;
            }
        }
        public ListColorsEvenElegantlier()
        {
            Title = "List Colors Even Elegantlier";

            DataTemplate template = new DataTemplate(typeof(NamedBrush));
            FrameworkElementFactory factoryStack = new FrameworkElementFactory(typeof(StackPanel));
            factoryStack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            template.VisualTree = factoryStack;

            FrameworkElementFactory factoryRectangle = new FrameworkElementFactory(typeof(Rectangle));
            factoryRectangle.SetValue(Rectangle.WidthProperty, 16.0);
            factoryRectangle.SetValue(Rectangle.HeightProperty, 16.0);
            factoryRectangle.SetValue(Rectangle.MarginProperty, new Thickness(2));
            factoryRectangle.SetValue(Rectangle.StrokeProperty, SystemColors.WindowTextBrush);
            factoryRectangle.SetBinding(Rectangle.FillProperty, new Binding("Brush"));
            factoryStack.AppendChild(factoryRectangle);

            FrameworkElementFactory factoryTextBlock = new FrameworkElementFactory(typeof(TextBlock));
            factoryTextBlock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
            factoryTextBlock.SetValue(TextBlock.TextProperty, new Binding("Name"));
            factoryStack.AppendChild(factoryTextBlock);

            ListBox lstbox = new ListBox();
            lstbox.Width = 150;
            lstbox.Height = 150;
            Content = lstbox;

            lstbox.ItemTemplate = template;
            lstbox.ItemsSource = NamedBrush.All;

            lstbox.SelectedValuePath = "Brush";
            lstbox.SetBinding(ListBox.SelectedValueProperty, "Background");
            lstbox.DataContext = this;
        }
		public static sw.FrameworkElementFactory TextBlock()
		{
			var factory = new sw.FrameworkElementFactory(typeof(swc.TextBlock));
			factory.SetBinding(swc.TextBlock.TextProperty, new sw.Data.Binding { Path = TextPath });
			factory.SetValue(swc.TextBlock.MarginProperty, new sw.Thickness(2));
			return factory;
		}
Beispiel #25
0
    public static void ApplyAutogeneratedColumnAttributes(DataGridAutoGeneratingColumnEventArgs e)
    {
      PropertyDescriptor pd = e.PropertyDescriptor as PropertyDescriptor;
      if (pd.Attributes[typeof(HiddenColumn)] != null)
      {
        e.Cancel = true;
        return;
      }

      DisplayNameAttribute nameAttribute = pd.Attributes[typeof(DisplayNameAttribute)] as DisplayNameAttribute;
      if (nameAttribute != null && !String.IsNullOrEmpty(nameAttribute.DisplayName))
      {
        e.Column.Header = nameAttribute.DisplayName;
      }

      ColumnWidth columnWidth = pd.Attributes[typeof(ColumnWidth)] as ColumnWidth;
      if (columnWidth != null)
      {
        e.Column.Width = columnWidth.Width;
      }

      if (e.PropertyType == typeof(double))
      {
        (e.Column as DataGridTextColumn).Binding.StringFormat = "{0:0.###}";
      }

			if (e.PropertyType == typeof(bool) && !e.Column.IsReadOnly)
			{
				var checkboxFactory = new FrameworkElementFactory(typeof(CheckBox));
				checkboxFactory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);
				checkboxFactory.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
				checkboxFactory.SetBinding(CheckBox.IsCheckedProperty, new Binding(e.PropertyName) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
				e.Column = new DataGridTemplateColumn { Header = e.Column.Header, CellTemplate = new DataTemplate { VisualTree = checkboxFactory }, SortMemberPath = e.Column.SortMemberPath };
			}
    }
        public ColorGridBox()
        {
            // Define the ItemsPanel template.
            FrameworkElementFactory factoryUnigrid =
                            new FrameworkElementFactory(typeof(UniformGrid));
            factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8);
            ItemsPanel = new ItemsPanelTemplate(factoryUnigrid);

            // Add items to the ListBox.
            foreach (string strColor in strColors)
            {
                // Create Rectangle and add to ListBox.
                Rectangle rect = new Rectangle();
                rect.Width = 12;
                rect.Height = 12;
                rect.Margin = new Thickness(4);
                rect.Fill = (Brush)
                    typeof(Brushes).GetProperty(strColor).GetValue(null, null);
                Items.Add(rect);

                // Create ToolTip for Rectangle.
                ToolTip tip = new ToolTip();
                tip.Content = strColor;
                rect.ToolTip = tip;
            }
            // Indicate that SelectedValue is Fill property of Rectangle item.
            SelectedValuePath = "Fill";
        }
        public ColorWheel()
        {
            // Define the ItemsPanel template.
            FrameworkElementFactory factoryRadialPanel =
                            new FrameworkElementFactory(typeof(RadialPanel));
            ItemsPanel = new ItemsPanelTemplate(factoryRadialPanel);

            // Create the DataTemplate for the items.
            DataTemplate template = new DataTemplate(typeof(Brush));
            ItemTemplate = template;

            // Create a FrameworkElementFactory based on Rectangle.
            FrameworkElementFactory elRectangle =
                                new FrameworkElementFactory(typeof(Rectangle));
            elRectangle.SetValue(Rectangle.WidthProperty, 4.0);
            elRectangle.SetValue(Rectangle.HeightProperty, 12.0);
            elRectangle.SetValue(Rectangle.MarginProperty,
                                        new Thickness(1, 8, 1, 8));
            elRectangle.SetBinding(Rectangle.FillProperty, new Binding(""));

            // Use that factory for the visual tree.
            template.VisualTree = elRectangle;

            // Set the items in the ListBox.
            PropertyInfo[] props = typeof(Brushes).GetProperties();

            foreach (PropertyInfo prop in props)
                Items.Add((Brush)prop.GetValue(null, null));
        }
Beispiel #28
0
        private void GenerateMetaColumns()
        {
            while (_gridView.Columns.Count > 1)
            {
                _gridView.Columns.RemoveAt(1);
            }

            // dynamically generate columns for meta data 
            var container = theView.DataContext as ContainerVM;
            if (container != null)
            {

                foreach (var info in container.KnownMetaData)
                {
                    GridViewColumn col = new GridViewColumn
                    {
                        Header = info.Name,
                        HeaderContainerStyle = TryFindResource(string.Format("{0}AlignColHeader", info.HeaderAlignment)) as Style,
                        Width = info.Width,
                    };
                    var txt = new FrameworkElementFactory(typeof(TextBlock));
                    txt.SetBinding(TextBlock.TextProperty, new Binding(string.Format("MetaData[{0}].Value", info.Name)) { Converter = info.Formatter, ConverterParameter = info.FormatParameter });
                    txt.SetValue(TextBlock.TextTrimmingProperty, TextTrimming.CharacterEllipsis);
                    txt.SetValue(TextBlock.TextAlignmentProperty, info.ContentAlignment);
                    col.CellTemplate = new DataTemplate() { VisualTree = txt };

                    _gridView.Columns.Add(col);
                }
            }
        }
Beispiel #29
0
		public EditableTextBlock()
		{
			var textBox = new FrameworkElementFactory(typeof(TextBox));
			textBox.SetValue(Control.PaddingProperty, new Thickness(1)); // 1px for border
			textBox.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(TextBox_Loaded));
			textBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
			textBox.AddHandler(UIElement.LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
			textBox.SetBinding(TextBox.TextProperty, new System.Windows.Data.Binding("Text") { Source = this, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
			var editTemplate = new DataTemplate { VisualTree = textBox };

			var textBlock = new FrameworkElementFactory(typeof(TextBlock));
			textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2));
			textBlock.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(TextBlock_MouseDown));
			textBlock.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("Text") { Source = this });
			var viewTemplate = new DataTemplate { VisualTree = textBlock };

			var style = new System.Windows.Style(typeof(EditableTextBlock));
			var trigger = new Trigger { Property = IsInEditModeProperty, Value = true };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = editTemplate });
			style.Triggers.Add(trigger);

			trigger = new Trigger { Property = IsInEditModeProperty, Value = false };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = viewTemplate });
			style.Triggers.Add(trigger);
			Style = style;
		}
Beispiel #30
0
		internal static FrameworkElementFactory CreateBoundColumnTemplate (ApplicationContext ctx, Widget parent, CellViewCollection views, string dataPath = ".")
		{
			if (views.Count == 1)
                return CreateBoundCellRenderer(ctx, parent, views[0], dataPath);
			
			FrameworkElementFactory container = new FrameworkElementFactory (typeof (StackPanel));
			container.SetValue (StackPanel.OrientationProperty, System.Windows.Controls.Orientation.Horizontal);

			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);

				container.AppendChild(factory);
			}

			return container;
		}
Beispiel #31
0
        public static sw.FrameworkElementFactory ItemTemplate(bool editable, swd.RelativeSource relativeSource = null)
        {
            var factory = new sw.FrameworkElementFactory(typeof(swc.StackPanel));

            factory.SetValue(swc.StackPanel.OrientationProperty, swc.Orientation.Horizontal);
            factory.AppendChild(ImageBlock());
            factory.AppendChild(editable ? EditableBlock(relativeSource) : TextBlock());
            return(factory);
        }
Beispiel #32
0
        public static sw.FrameworkElementFactory ItemTemplate()
        {
            var factory = new sw.FrameworkElementFactory(typeof(swc.StackPanel));

            factory.SetValue(swc.StackPanel.OrientationProperty, swc.Orientation.Horizontal);
            factory.AppendChild(ImageBlock());
            factory.AppendChild(TextBlock());
            return(factory);
        }
Beispiel #33
0
        public static sw.FrameworkElementFactory TextBlock()
        {
            var factory = new sw.FrameworkElementFactory(typeof(swc.TextBlock));

            factory.SetBinding(swc.TextBlock.TextProperty, new sw.Data.Binding {
                Converter = new TextConverter()
            });
            return(factory);
        }
Beispiel #34
0
        public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource)
        {
            var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock));
            var binding = new sw.Data.Binding {
                Path = new sw.PropertyPath("Text"), RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.LostFocus
            };

            factory.SetBinding(EditableTextBlock.TextProperty, binding);
            return(factory);
        }
Beispiel #35
0
        public static sw.FrameworkElementFactory TextBlock()
        {
            var factory = new sw.FrameworkElementFactory(typeof(swc.TextBlock));

            factory.SetBinding(swc.TextBlock.TextProperty, new sw.Data.Binding {
                Path = TextPath
            });
            factory.SetValue(swc.TextBlock.MarginProperty, new sw.Thickness(2));
            return(factory);
        }
 public static System.Windows.Controls.ListView useWrapPanel(this System.Windows.Controls.ListView listView)
 {
     listView.wpfInvoke(
         () => {
         var frameworkElementFactory = new System.Windows.FrameworkElementFactory(typeof(WrapPanel));
         //frameworkElementFactory.SetValue(WrapPanel.OrientationProperty, Orientation.Vertical);
         var itemsPanelTemplate = new ItemsPanelTemplate(frameworkElementFactory);
         listView.ItemsPanel    = itemsPanelTemplate;
     });
     return(listView);
 }
Beispiel #37
0
        public static sw.FrameworkElementFactory ImageBlock()
        {
            var factory = new sw.FrameworkElementFactory(typeof(swc.Image));

            factory.SetValue(sw.FrameworkElement.MaxHeightProperty, 16.0);
            factory.SetValue(sw.FrameworkElement.MaxWidthProperty, 16.0);
            factory.SetValue(swc.Image.StretchDirectionProperty, swc.StretchDirection.DownOnly);
            factory.SetValue(sw.FrameworkElement.MarginProperty, new sw.Thickness(0, 2, 2, 2));
            factory.SetBinding(swc.Image.SourceProperty, new sw.Data.Binding {
                Converter = new ImageConverter()
            });
            return(factory);
        }
Beispiel #38
0
        public static sw.FrameworkElementFactory TextBlock(bool setMargin = true)
        {
            var factory = new sw.FrameworkElementFactory(typeof(swc.TextBlock));

            factory.SetBinding(swc.TextBlock.TextProperty, new sw.Data.Binding {
                Path = new sw.PropertyPath("Text")
            });
            if (setMargin)
            {
                factory.SetValue(sw.FrameworkElement.MarginProperty, new sw.Thickness(2));
            }
            return(factory);
        }
Beispiel #39
0
        private void AddRatingColumn(string header, int width, string bindingPath)
        {
            DataGridTemplateColumn nc = new DataGridTemplateColumn();

            System.Windows.DataTemplate template = new System.Windows.DataTemplate();

            System.Windows.FrameworkElementFactory factoryRatingControl = new System.Windows.FrameworkElementFactory(typeof(RatingUserControl));

            System.Windows.Data.Binding binding = new System.Windows.Data.Binding(bindingPath);
            //binding.Converter = new Int32Converter();
            factoryRatingControl.SetBinding(RatingUserControl.RatingProperty, binding);
            factoryRatingControl.SetValue(RatingUserControl.HorizontalAlignmentProperty, System.Windows.HorizontalAlignment.Left);
            factoryRatingControl.SetValue(RatingUserControl.ReadOnlyProperty, true);

            template.VisualTree = factoryRatingControl;

            nc.CellTemplate = template;
            nc.Header       = header;
            nc.Width        = width;
            nc.IsReadOnly   = true;
            dataGrid.Columns.Add(nc);
        }
        /// <summary>
        /// Legt die erste Spalte mit den Play-Controls für die Wiedergabe an.
        /// </summary>
        private void CreatePlayControlColumn()
        {
            DataGridTemplateColumn nc = new DataGridTemplateColumn();

            System.Windows.DataTemplate template = new System.Windows.DataTemplate();

            System.Windows.FrameworkElementFactory factoryAddToPlaylistUserControl = new System.Windows.FrameworkElementFactory(typeof(AddToPlaylistUserControl));

            factoryAddToPlaylistUserControl.AddHandler(AddToPlaylistUserControl.PlayNowEvent, new System.Windows.RoutedEventHandler(AddToPlaylistPlayNow));
            factoryAddToPlaylistUserControl.AddHandler(AddToPlaylistUserControl.PlayNextEvent, new System.Windows.RoutedEventHandler(AddToPlaylistPlayNext));
            factoryAddToPlaylistUserControl.AddHandler(AddToPlaylistUserControl.PlayLastEvent, new System.Windows.RoutedEventHandler(AddToPlaylistPlayLast));
            factoryAddToPlaylistUserControl.AddHandler(AddToPlaylistUserControl.PreListenEvent, new System.Windows.RoutedEventHandler(AddToPlaylistPreListen));

            template.VisualTree = factoryAddToPlaylistUserControl;
            nc.CanUserSort      = true;
            nc.CellTemplate     = template;
            nc.Header           = "";
            nc.Width            = 66;
            nc.IsReadOnly       = true;

            dataGrid.Columns.Add(nc);
        }
        // Token: 0x06000691 RID: 1681 RVA: 0x00014908 File Offset: 0x00012B08
        internal DependencyObject InstantiateTree(UncommonField <HybridDictionary[]> dataField, DependencyObject container, DependencyObject parent, List <DependencyObject> affectedChildren, ref List <DependencyObject> noChildIndexChildren, ref FrugalStructList <ChildPropertyDependent> resourceDependents)
        {
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose, EventTrace.Event.WClientParseFefCrInstBegin);
            FrameworkElement frameworkElement = container as FrameworkElement;
            bool             flag             = frameworkElement != null;
            DependencyObject dependencyObject = null;

            if (this._text != null)
            {
                IAddChild addChild = parent as IAddChild;
                if (addChild == null)
                {
                    throw new InvalidOperationException(SR.Get("TypeMustImplementIAddChild", new object[]
                    {
                        parent.GetType().Name
                    }));
                }
                addChild.AddText(this._text);
            }
            else
            {
                dependencyObject = this.CreateDependencyObject();
                EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose, EventTrace.Event.WClientParseFefCrInstEnd);
                FrameworkObject frameworkObject = new FrameworkObject(dependencyObject);
                Visual3D        visual3D        = null;
                bool            flag2           = false;
                if (!frameworkObject.IsValid)
                {
                    visual3D = (dependencyObject as Visual3D);
                    if (visual3D != null)
                    {
                        flag2 = true;
                    }
                }
                bool isFE = frameworkObject.IsFE;
                if (!flag2)
                {
                    FrameworkElementFactory.NewNodeBeginInit(isFE, frameworkObject.FE, frameworkObject.FCE);
                    if (StyleHelper.HasResourceDependentsForChild(this._childIndex, ref resourceDependents))
                    {
                        frameworkObject.HasResourceReference = true;
                    }
                    FrameworkElementFactory.UpdateChildChains(this._childName, this._childIndex, isFE, frameworkObject.FE, frameworkObject.FCE, affectedChildren, ref noChildIndexChildren);
                    FrameworkElementFactory.NewNodeStyledParentProperty(container, flag, isFE, frameworkObject.FE, frameworkObject.FCE);
                    if (this._childIndex != -1)
                    {
                        StyleHelper.CreateInstanceDataForChild(dataField, container, dependencyObject, this._childIndex, this._frameworkTemplate.HasInstanceValues, ref this._frameworkTemplate.ChildRecordFromChildIndex);
                    }
                    if (this.HasLoadedChangeHandler)
                    {
                        BroadcastEventHelper.AddHasLoadedChangeHandlerFlagInAncestry(dependencyObject);
                    }
                }
                else if (this._childName != null)
                {
                    affectedChildren.Add(dependencyObject);
                }
                else
                {
                    if (noChildIndexChildren == null)
                    {
                        noChildIndexChildren = new List <DependencyObject>(4);
                    }
                    noChildIndexChildren.Add(dependencyObject);
                }
                if (container == parent)
                {
                    TemplateNameScope value = new TemplateNameScope(container);
                    NameScope.SetNameScope(dependencyObject, value);
                    if (flag)
                    {
                        frameworkElement.TemplateChild = frameworkObject.FE;
                    }
                    else
                    {
                        FrameworkElementFactory.AddNodeToLogicalTree((FrameworkContentElement)parent, this._type, isFE, frameworkObject.FE, frameworkObject.FCE);
                    }
                }
                else
                {
                    this.AddNodeToParent(parent, frameworkObject);
                }
                if (!flag2)
                {
                    StyleHelper.InvalidatePropertiesOnTemplateNode(container, frameworkObject, this._childIndex, ref this._frameworkTemplate.ChildRecordFromChildIndex, false, this);
                }
                else
                {
                    for (int i = 0; i < this.PropertyValues.Count; i++)
                    {
                        if (this.PropertyValues[i].ValueType != PropertyValueType.Set)
                        {
                            throw new NotSupportedException(SR.Get("Template3DValueOnly", new object[]
                            {
                                this.PropertyValues[i].Property
                            }));
                        }
                        object    obj       = this.PropertyValues[i].ValueInternal;
                        Freezable freezable = obj as Freezable;
                        if (freezable != null && !freezable.CanFreeze)
                        {
                            obj = freezable.Clone();
                        }
                        MarkupExtension markupExtension = obj as MarkupExtension;
                        if (markupExtension != null)
                        {
                            ProvideValueServiceProvider provideValueServiceProvider = new ProvideValueServiceProvider();
                            provideValueServiceProvider.SetData(visual3D, this.PropertyValues[i].Property);
                            obj = markupExtension.ProvideValue(provideValueServiceProvider);
                        }
                        visual3D.SetValue(this.PropertyValues[i].Property, obj);
                    }
                }
                for (FrameworkElementFactory frameworkElementFactory = this._firstChild; frameworkElementFactory != null; frameworkElementFactory = frameworkElementFactory._nextSibling)
                {
                    frameworkElementFactory.InstantiateTree(dataField, container, dependencyObject, affectedChildren, ref noChildIndexChildren, ref resourceDependents);
                }
                if (!flag2)
                {
                    FrameworkElementFactory.NewNodeEndInit(isFE, frameworkObject.FE, frameworkObject.FCE);
                }
            }
            return(dependencyObject);
        }
Beispiel #42
0
        private void CreateHeader(ColumnFieldCollection fields)
        {
            dataGrid.Columns.Clear();

            //Int32Converter int32Conv = new Int32Converter();

            int i = 0;

            foreach (ColumnField field in fields)
            {
                Type   columnType = DataBase.GetTypeByField(field.Field);
                int    width      = field.Width;
                string columnName = DataBase.GetNameOfField(field.Field, false);

                switch (field.Field)
                {
                case Field.Rating:
                {
                    DataGridRatingColumn nc = new DataGridRatingColumn();

                    System.Windows.DataTemplate template = new System.Windows.DataTemplate();

                    System.Windows.FrameworkElementFactory factoryRatingControl = new System.Windows.FrameworkElementFactory(typeof(RatingUserControl));

                    System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Items[" + i + "]");
                    binding.Mode = BindingMode.TwoWay;
                    //binding.Converter = int32Conv;
                    factoryRatingControl.SetBinding(RatingUserControl.RatingProperty, binding);
                    factoryRatingControl.SetValue(RatingUserControl.HorizontalAlignmentProperty, System.Windows.HorizontalAlignment.Left);
                    factoryRatingControl.AddHandler(RatingUserControl.MouseLeftButtonDownEvent, new MouseButtonEventHandler(RatingCell_MouseLeftButtonDown));

                    nc.SetValue(DataGridExtensions.FieldProperty, field.Field);
                    //factoryRatingControl.SetValue(RatingUserControl.ReadOnlyProperty, true);

                    template.VisualTree = factoryRatingControl;
                    nc.CanUserSort      = true;
                    nc.CellTemplate     = template;
                    //nc.CellEditingTemplate = template;
                    nc.Header = columnName;
                    nc.Width  = width;
                    // Auf Read-Only setzen, da wir das manuell machen (im MouseLeftButtonDown)
                    nc.IsReadOnly     = true;
                    nc.SortMemberPath = "Items[" + i + "]";

                    dataGrid.Columns.Add(nc);
                    break;
                }

                case Field.Comment:
                {
                    DataGridTemplateColumn newMultilineColumn = new DataGridTemplateColumn();
                    newMultilineColumn.Width  = field.Width;
                    newMultilineColumn.Header = DataBase.GetNameOfField(field.Field);
                    newMultilineColumn.SetValue(DataGridExtensions.FieldProperty, field.Field);

                    DataTemplate multilineCelltemplate = this.FindResource("CommentTemplate") as DataTemplate;
                    newMultilineColumn.CellTemplate        = multilineCelltemplate;
                    newMultilineColumn.CellEditingTemplate = multilineCelltemplate;

                    dataGrid.Columns.Add(newMultilineColumn);
                    break;
                }

                default:
                {
                    DataGridMaxLengthTextColumn nc = new DataGridMaxLengthTextColumn();
                    nc.SetValue(DataGridExtensions.FieldProperty, field.Field);
                    System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Items[" + i + "]");
                    if (field.Field == Field.TotalLength)
                    {
                        binding.Converter = new Big3.Hitbase.Miscellaneous.LengthConverter();
                    }
                    else if (field.Field == Field.Price)
                    {
                        binding.Converter = new PriceConverter();
                    }
                    else if (field.Field == Field.Date)
                    {
                        binding.Converter          = new DataBaseDateConverter();
                        binding.ConverterParameter = this.DataBase;
                    }
                    else if (field.Field == Field.AlbumType)
                    {
                        binding.Converter = new AlbumTypeConverter();
                        nc.IsReadOnly     = true;
                    }
                    else if (IsUserFieldDateFormat(field.Field))
                    {
                        binding.Converter = new UserFieldDateConverter();
                    }
                    else if (DataBase.GetTypeByField(field.Field) == typeof(int))
                    {
                        binding.Converter = new MyInt32Converter();
                    }
                    else if (DataBase.GetTypeByField(field.Field) == typeof(bool))
                    {
                        binding.Converter = new BoolConverter();
                    }

                    nc.Binding = binding;
                    nc.Header  = columnName;
                    nc.Width   = width;

                    if (DataBase.GetTypeByField(field.Field) == typeof(string))
                    {
                        nc.MaxLength = DataBase.GetMaxStringLength(field.Field);
                    }
                    //nc.IsReadOnly = true;

                    dataGrid.Columns.Add(nc);
                    break;
                }
                }

                i++;
            }

            CurrentFields = fields;
        }
Beispiel #43
0
 public void AppendChild(FrameworkElementFactory child)
 {
 }
        private DockPanel CreateUI()
        {
            DockPanel collision_dock_panel = new DockPanel()
            {
                LastChildFill = true
            };

            StackPanel collision_stack_panel = new StackPanel()
            {
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch,
            };

            RowDefinition tree_row       = new RowDefinition();
            RowDefinition splitter_row   = new RowDefinition();
            RowDefinition properties_row = new RowDefinition();

            tree_row.Height          = System.Windows.GridLength.Auto;
            tree_row.MaxHeight       = 500;
            tree_row.MinHeight       = 10;
            splitter_row.Height      = System.Windows.GridLength.Auto;
            properties_row.Height    = System.Windows.GridLength.Auto;
            properties_row.MinHeight = 80;

            Grid col_grid = new Grid();

            col_grid.RowDefinitions.Add(tree_row);
            col_grid.RowDefinitions.Add(splitter_row);
            col_grid.RowDefinitions.Add(properties_row);

            System.Windows.HierarchicalDataTemplate template = new System.Windows.HierarchicalDataTemplate(typeof(CollisionGroupNode));
            template.ItemsSource = new Binding("Children");

            System.Windows.FrameworkElementFactory tb = new System.Windows.FrameworkElementFactory(typeof(TextBlock));
            tb.SetBinding(TextBlock.TextProperty, new Binding("Name"));
            tb.SetValue(TextBlock.ForegroundProperty, Brushes.Black);

            template.VisualTree = tb;

            m_CollisionTree = new TreeView()
            {
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
                ItemTemplate        = template
            };
            m_CollisionTree.SelectedItemChanged        += M_test_tree_SelectedItemChanged;
            m_CollisionTree.PreviewMouseLeftButtonDown += OnItemMouseDoubleClick;

            Grid.SetRow(m_CollisionTree, 0);

            GridSplitter splitter = new GridSplitter()
            {
                Height              = 5,
                VerticalAlignment   = System.Windows.VerticalAlignment.Top,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch
            };

            Grid.SetRow(splitter, 1);

            WDetailsView actor_details = new WDetailsView()
            {
                Name = "Details",
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch,
                DataContext         = DetailsViewModel
            };

            GroupBox actor_prop_box = new GroupBox()
            {
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch,
                Header  = "Properties",
                Content = actor_details,
            };

            Grid.SetRow(actor_prop_box, 2);

            col_grid.Children.Add(m_CollisionTree);
            col_grid.Children.Add(splitter);
            col_grid.Children.Add(actor_prop_box);

            DockPanel.SetDock(collision_stack_panel, Dock.Top);

            collision_stack_panel.Children.Add(col_grid);
            collision_dock_panel.Children.Add(collision_stack_panel);

            return(collision_dock_panel);
        }