/************************************************ * Constructors ***********************************************/ /// <summary> /// Initializes the static implementation of <see cref="Slideshow"/>. /// </summary> static Slideshow() { // Override the item template ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(SlideshowPanel))); template.Seal(); ItemsControl.ItemsPanelProperty.OverrideMetadata(typeof(Slideshow), new FrameworkPropertyMetadata(template)); }
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; }
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)); }
static ApplicationBar() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(typeof(ApplicationBar))); var itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(ApplicationBarPanel))); itemsPanelTemplate.Seal(); ItemsPanelProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(itemsPanelTemplate)); IsTabStopProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(false)); FocusableProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(false)); FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(true)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata( typeof(ApplicationBar), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata( typeof(ApplicationBar), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata( typeof(ApplicationBar), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once)); HorizontalAlignmentProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(HorizontalAlignment.Stretch)); VerticalAlignmentProperty.OverrideMetadata(typeof(ApplicationBar), new FrameworkPropertyMetadata(VerticalAlignment.Bottom)); EventManager.RegisterClassHandler(typeof(ApplicationBar), Mouse.LostMouseCaptureEvent, new MouseEventHandler(OnLostMouseCapture)); EventManager.RegisterClassHandler(typeof(ApplicationBar), Mouse.PreviewMouseUpOutsideCapturedElementEvent, new MouseButtonEventHandler(OnPreviewMouseButtonOutsideCapturedElement)); }
private static ItemsPanelTemplate GetDefaultPanel() { FrameworkElementFactory panel = new FrameworkElementFactory(typeof(WrapPanel)); ItemsPanelTemplate template = new ItemsPanelTemplate(panel); template.Seal(); return template; }
protected override void OnItemsPanelChanged(ItemsPanelTemplate oldItemsPanel, ItemsPanelTemplate newItemsPanel) { // This is not the actual WrappableStackPanel that will be used as the ItemsPanel. // This is another instance, and I use the field only for existence, not reference. isWrappableStackPanel = (newItemsPanel.LoadContent() as WrappableStackPanel) != null; base.OnItemsPanelChanged(oldItemsPanel, newItemsPanel); }
private static ItemsPanelTemplate GetDefaultPanel() { FrameworkElementFactory panel = new FrameworkElementFactory(typeof(WrapPanel)); ItemsPanelTemplate template = new ItemsPanelTemplate(panel); template.Seal(); return(template); }
static GroupStyle() { ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(StackPanel))); template.Seal(); DefaultGroupPanel = template; s_DefaultGroupStyle = new GroupStyle(); }
// Token: 0x060051C0 RID: 20928 RVA: 0x0016DED0 File Offset: 0x0016C0D0 private static ItemsPanelTemplate GetDefaultPanel() { FrameworkElementFactory root = new FrameworkElementFactory(typeof(WrapPanel)); ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate(root); itemsPanelTemplate.Seal(); return(itemsPanelTemplate); }
public DataGridFootersPresenter() { Background = new SolidColorBrush(Colors.Transparent); var elementFactory = new FrameworkElementFactory(typeof (StackPanel)); elementFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); ItemsPanel = new ItemsPanelTemplate {VisualTree = elementFactory}; }
static TileControl() { var itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(TilePanel))); itemsPanelTemplate.Seal(); ItemsControl.ItemsPanelProperty.OverrideMetadata(typeof(TileControl), new FrameworkPropertyMetadata(itemsPanelTemplate)); DefaultStyleKeyProperty.OverrideMetadata(typeof(TileControl), new FrameworkPropertyMetadata(typeof(ItemsControl))); }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ // initialize (called during measure, from ApplyTemplate) void AttachToOwner() { DependencyObject templatedParent = this.TemplatedParent; ItemsControl owner = templatedParent as ItemsControl; ItemContainerGenerator generator; if (owner != null) { // top-level presenter - get information from ItemsControl generator = owner.ItemContainerGenerator; } else { // subgroup presenter - get information from GroupItem GroupItem parentGI = templatedParent as GroupItem; ItemsPresenter parentIP = FromGroupItem(parentGI); if (parentIP != null) { owner = parentIP.Owner; } generator = (parentGI != null) ? parentGI.Generator : null; } _owner = owner; UseGenerator(generator); // create the panel, based either on ItemsControl.ItemsPanel or GroupStyle.Panel ItemsPanelTemplate template = null; GroupStyle groupStyle = (_generator != null) ? _generator.GroupStyle : null; if (groupStyle != null) { // If GroupStyle.Panel is set then we dont honor ItemsControl.IsVirtualizing template = groupStyle.Panel; if (template == null) { // create default Panels if (VirtualizingPanel.GetIsVirtualizingWhenGrouping(owner)) { template = GroupStyle.DefaultVirtualizingStackPanel; } else { template = GroupStyle.DefaultStackPanel; } } } else { // Its a leaf-level ItemsPresenter, therefore pick ItemsControl.ItemsPanel template = (_owner != null) ? _owner.ItemsPanel : null; } Template = template; }
static DialogBackend() { var panelFactory = new FrameworkElementFactory (typeof (StackPanel)); panelFactory.SetValue (StackPanel.OrientationProperty, SWC.Orientation.Horizontal); PanelTemplate = new ItemsPanelTemplate (panelFactory); ButtonStyle.Setters.Add (new Setter (FrameworkElement.MarginProperty, new Thickness (5))); ButtonStyle.Setters.Add (new Setter (FrameworkElement.MinWidthProperty, 80d)); }
public SelectableVirtualizingTreeViewItem() { var panelfactory = new FrameworkElementFactory(typeof(SelectableVirtualizingStackPanel)); panelfactory.SetValue(Panel.IsItemsHostProperty, true); var template = new ItemsPanelTemplate { VisualTree = panelfactory }; ItemsPanel = template; SetBinding(IsSelectedProperty, new Binding("IsSelected")); SetBinding(IsExpandedProperty, new Binding("IsExpanded")); }
/// <summary> /// Initializes static members of the RibbonContextMenu class. /// </summary> static RibbonContextMenu() { Type ownerType = typeof(RibbonContextMenu); DefaultStyleKeyProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(ownerType)); IsOpenProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(new PropertyChangedCallback(OnIsOpenChanged))); EventManager.RegisterClassHandler(ownerType, Mouse.PreviewMouseDownOutsideCapturedElementEvent, new MouseButtonEventHandler(OnClickThroughThunk)); ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(RibbonMenuItemsPanel))); template.Seal(); ItemsPanelProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(template)); }
static Controls() { ResourceDictionary rd = Helper.GetDictionary("Controls", "LocalizedResource"); LocalizedText = (DataTemplate)rd["LocalizedText"]; LocalizedDataText = (DataTemplate)rd["LocalizedDataText"]; rd = Helper.GetDictionary("Controls", "XButton"); XButton = (Style)rd["XButton"]; rd = Helper.GetDictionary("Controls", "Controls"); CommandMenu = (Style)rd["CommandMenu"]; WrapPanel = (ItemsPanelTemplate)rd["WrapPanelTemplate"]; }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; System.Windows.Application.LoadComponent(this, new System.Uri("/LuckyDraw;component/MainPage.xaml", System.UriKind.Relative)); this.MainCanvas = ((System.Windows.Controls.Canvas)(this.FindName("MainCanvas"))); this.btnSpin = ((System.Windows.Controls.Button)(this.FindName("btnSpin"))); this.DataWheel = ((System.Windows.Controls.ListBox)(this.FindName("DataWheel"))); this.DataWheel_Rotate = ((System.Windows.Media.RotateTransform)(this.FindName("DataWheel_Rotate"))); this.RadialPanelItemTemplate = ((System.Windows.Controls.ItemsPanelTemplate)(this.FindName("RadialPanelItemTemplate"))); }
public PlanObjectsSelector() { CanSelectMultipleItems = true; ClipToBounds = true; var panel = new FrameworkElementFactory(typeof(Canvas)); ItemsPanel = new ItemsPanelTemplate(panel); ItemContainerStyle = new Style(); ItemContainerStyle.Setters.Add(new Setter(Canvas.LeftProperty, new Binding("Left"))); ItemContainerStyle.Setters.Add(new Setter(Canvas.TopProperty, new Binding("Top"))); }
static TreeView() { DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeView), new FrameworkPropertyMetadata(typeof(TreeView))); FrameworkElementFactory vPanel = new FrameworkElementFactory(typeof(VirtualizingTreePanel)); vPanel.SetValue(Panel.IsItemsHostProperty, true); ItemsPanelTemplate vPanelTemplate = new ItemsPanelTemplate { VisualTree = vPanel }; ItemsPanelProperty.OverrideMetadata(typeof(TreeView), new FrameworkPropertyMetadata(vPanelTemplate)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(TreeView), new FrameworkPropertyMetadata(KeyboardNavigationMode.Contained)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(TreeView), new FrameworkPropertyMetadata(KeyboardNavigationMode.None)); }
// Token: 0x06004DE3 RID: 19939 RVA: 0x0015F798 File Offset: 0x0015D998 static GroupStyle() { ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(StackPanel))); itemsPanelTemplate.Seal(); GroupStyle.DefaultGroupPanel = itemsPanelTemplate; GroupStyle.DefaultStackPanel = itemsPanelTemplate; itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(VirtualizingStackPanel))); itemsPanelTemplate.Seal(); GroupStyle.DefaultVirtualizingStackPanel = itemsPanelTemplate; GroupStyle.s_DefaultGroupStyle = new GroupStyle(); }
public ExperienceControl() { FrameworkElementFactory fGrid = new FrameworkElementFactory(typeof(System.Windows.Controls.Primitives.UniformGrid)); fGrid.SetValue(System.Windows.Controls.Primitives.UniformGrid.ColumnsProperty, 7); ItemsPanel = new ItemsPanelTemplate(fGrid); for (int i = 0; i < _States.Length; i++) { if (i == 1) { ListBoxItem lbiSeperator = new ListBoxItem(); lbiSeperator.IsEnabled = false; lbiSeperator.Width = 5; Rectangle seperator = new Rectangle(); seperator.Width = 5; seperator.Height = 23; seperator.Margin = new Thickness(1); seperator.Fill = new SolidColorBrush(Colors.Black); lbiSeperator.Content = seperator; Items.Add(lbiSeperator); } ListBoxItem lbi = new ListBoxItem(); lbi.VerticalAlignment = VerticalAlignment.Bottom; lbi.Height = 23; Rectangle item = new Rectangle(); item.Width = 10; item.Height = 5 * (i / 1.75) + 5; item.Margin = new Thickness(1); item.Fill = new SolidColorBrush(_States[i].Color); ToolTip t = new ToolTip(); t.Content = _States[i].Name; item.ToolTip = t; lbi.ToolTip = t; lbi.Content = item; Items.Add(lbi); } this.MaxHeight = 30; this.MaxWidth = 120; this.VerticalAlignment = VerticalAlignment.Bottom; SelectedValuePath = "Fill"; }
private Panel _itemsHost; // ItemsPanel instance for this ItemsControl #endregion Fields #region Constructors static RibbonContextualTabGroupItemsControl() { Type ownerType = typeof(RibbonContextualTabGroupItemsControl); DefaultStyleKeyProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(ownerType)); ItemTemplateProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(null, OnNotifyPropertyChanged, CoerceItemTemplate)); ItemContainerStyleProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(null, OnNotifyPropertyChanged, CoerceItemContainerStyle)); VisibilityProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(null, new CoerceValueCallback(CoerceVisibility))); FocusableProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(false)); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(RibbonContextualTabGroupsPanel)); ItemsPanelTemplate itemsPanel = new ItemsPanelTemplate(factory); itemsPanel.Seal(); ItemsPanelProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(itemsPanel)); }
static TreeViewEx() { DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeViewEx), new FrameworkPropertyMetadata(typeof(TreeViewEx))); FrameworkElementFactory vPanel = new FrameworkElementFactory(typeof(VirtualizingTreePanel)); vPanel.SetValue(VirtualizingTreePanel.IsItemsHostProperty, true); ItemsPanelTemplate vPanelTemplate = new ItemsPanelTemplate(); vPanelTemplate.VisualTree = vPanel; ItemsPanelProperty.OverrideMetadata(typeof(TreeViewEx), new FrameworkPropertyMetadata(vPanelTemplate)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(TreeViewEx), new FrameworkPropertyMetadata(KeyboardNavigationMode.Contained)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(TreeViewEx), new FrameworkPropertyMetadata(KeyboardNavigationMode.None)); }
/// <summary> /// Initializes static members of the RibbonControlGroup class. /// </summary> static RibbonControlGroup() { Type ownerType = typeof(RibbonControlGroup); DefaultStyleKeyProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(ownerType)); FocusableProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(false)); FrameworkElementFactory fef = new FrameworkElementFactory(typeof(StackPanel)); fef.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); ItemsPanelTemplate template = new ItemsPanelTemplate(fef); template.Seal(); ItemsPanelProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(template)); RibbonControlService.DefaultControlSizeDefinitionProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(null, new CoerceValueCallback(CoerceDefaultControlSizeDefinition))); }
static GroupByControl() { // This DefaultStyleKey will only be used in design-time. DefaultStyleKeyProperty.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( new Markup.ThemeKey( typeof( Views.TableView ), typeof( GroupByControl ) ) ) ); FrameworkElementFactory staircaseFactory = new FrameworkElementFactory( typeof( StaircasePanel ) ); ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate( staircaseFactory ); RelativeSource ancestorSource = new RelativeSource( RelativeSourceMode.FindAncestor, typeof( GroupByControl ), 1 ); Binding binding = new Binding(); binding.Path = new PropertyPath( GroupByControl.ConnectionLineAlignmentProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.ConnectionLineAlignmentProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( GroupByControl.ConnectionLineOffsetProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.ConnectionLineOffsetProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( GroupByControl.ConnectionLinePenProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.ConnectionLinePenProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( GroupByControl.StairHeightProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.StairHeightProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( GroupByControl.StairSpacingProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.StairSpacingProperty, binding ); itemsPanelTemplate.Seal(); ItemsControl.ItemsPanelProperty.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( itemsPanelTemplate ) ); DataGridControl.ParentDataGridControlPropertyKey.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( new PropertyChangedCallback( GroupByControl.ParentGridControlChangedCallback ) ) ); DataGridControl.DataGridContextPropertyKey.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( new PropertyChangedCallback( GroupByControl.DataGridContextChangedCallback ) ) ); FocusableProperty.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( false ) ); }
/// <summary> /// Constructor /// </summary> public SimpleView() { if (!_templateSet) { try { var defaultTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(Grid))); defaultTemplate.Seal(); ItemsPanelProperty.OverrideMetadata(typeof(SimpleView), new FrameworkPropertyMetadata(defaultTemplate)); _templateSet = true; } catch { } } OriginalViewLoadLocation = string.Empty; }
// Token: 0x0600510F RID: 20751 RVA: 0x0016BAE4 File Offset: 0x00169CE4 private void AttachToOwner() { DependencyObject templatedParent = base.TemplatedParent; ItemsControl itemsControl = templatedParent as ItemsControl; ItemContainerGenerator generator; if (itemsControl != null) { generator = itemsControl.ItemContainerGenerator; } else { GroupItem groupItem = templatedParent as GroupItem; ItemsPresenter itemsPresenter = ItemsPresenter.FromGroupItem(groupItem); if (itemsPresenter != null) { itemsControl = itemsPresenter.Owner; } generator = ((groupItem != null) ? groupItem.Generator : null); } this._owner = itemsControl; this.UseGenerator(generator); GroupStyle groupStyle = (this._generator != null) ? this._generator.GroupStyle : null; ItemsPanelTemplate itemsPanelTemplate; if (groupStyle != null) { itemsPanelTemplate = groupStyle.Panel; if (itemsPanelTemplate == null) { if (VirtualizingPanel.GetIsVirtualizingWhenGrouping(itemsControl)) { itemsPanelTemplate = GroupStyle.DefaultVirtualizingStackPanel; } else { itemsPanelTemplate = GroupStyle.DefaultStackPanel; } } } else { itemsPanelTemplate = ((this._owner != null) ? this._owner.ItemsPanel : null); } this.Template = itemsPanelTemplate; }
// Token: 0x06005120 RID: 20768 RVA: 0x0016BF34 File Offset: 0x0016A134 static ListBox() { FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(typeof(ListBox))); ListBox._dType = DependencyObjectType.FromSystemTypeInternal(typeof(ListBox)); Control.IsTabStopProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(KeyboardNavigationMode.Contained)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once)); ItemsControl.IsTextSearchEnabledProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(BooleanBoxes.TrueBox)); ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(VirtualizingStackPanel))); itemsPanelTemplate.Seal(); ItemsControl.ItemsPanelProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(itemsPanelTemplate)); EventManager.RegisterClassHandler(typeof(ListBox), Mouse.MouseUpEvent, new MouseButtonEventHandler(ListBox.OnMouseButtonUp), true); EventManager.RegisterClassHandler(typeof(ListBox), Keyboard.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(ListBox.OnGotKeyboardFocus)); CommandHelpers.RegisterCommandHandler(typeof(ListBox), ListBox.SelectAllCommand, new ExecutedRoutedEventHandler(ListBox.OnSelectAll), new CanExecuteRoutedEventHandler(ListBox.OnQueryStatusSelectAll), KeyGesture.CreateFromResourceStrings(SR.Get("ListBoxSelectAllKey"), SR.Get("ListBoxSelectAllKeyDisplayString"))); ControlsTraceLogger.AddControl(TelemetryControls.ListBox); }
public ColorWheel() { FrameworkElementFactory factoryRadialPanel = new FrameworkElementFactory(typeof(RadialPanel)); ItemsPanel = new ItemsPanelTemplate(factoryRadialPanel); DataTemplate template = new DataTemplate(typeof(Brush)); ItemTemplate = template; 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("")); template.VisualTree = elRectangle; PropertyInfo[] props = typeof(Brushes).GetProperties(); foreach (PropertyInfo prop in props) Items.Add((Brush)prop.GetValue(null,null)); }
static HierarchicalGroupByControlNode() { // Default binding to HierarchicalGroupByControlNode value FrameworkElementFactory staircaseFactory = new FrameworkElementFactory( typeof( StaircasePanel ) ); ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate( staircaseFactory ); RelativeSource ancestorSource = new RelativeSource( RelativeSourceMode.FindAncestor, typeof( HierarchicalGroupByControl ), 1 ); Binding binding = new Binding(); binding.Path = new PropertyPath( HierarchicalGroupByControlNode.ConnectionLineAlignmentProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.ConnectionLineAlignmentProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( HierarchicalGroupByControlNode.ConnectionLineOffsetProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.ConnectionLineOffsetProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( HierarchicalGroupByControlNode.ConnectionLinePenProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.ConnectionLinePenProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( HierarchicalGroupByControlNode.StairHeightProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.StairHeightProperty, binding ); binding = new Binding(); binding.Path = new PropertyPath( HierarchicalGroupByControlNode.StairSpacingProperty ); binding.Mode = BindingMode.OneWay; binding.RelativeSource = ancestorSource; staircaseFactory.SetBinding( StaircasePanel.StairSpacingProperty, binding ); itemsPanelTemplate.Seal(); ItemsControl.ItemsPanelProperty.OverrideMetadata( typeof( HierarchicalGroupByControlNode ), new FrameworkPropertyMetadata( itemsPanelTemplate ) ); DataGridControl.ParentDataGridControlPropertyKey.OverrideMetadata( typeof( HierarchicalGroupByControlNode ), new FrameworkPropertyMetadata( new PropertyChangedCallback( HierarchicalGroupByControlNode.ParentGridControlChangedCallback ) ) ); FocusableProperty.OverrideMetadata( typeof( HierarchicalGroupByControlNode ), new FrameworkPropertyMetadata( false ) ); }
void EndlessGrid_Loaded(object sender, RoutedEventArgs e) { // Create ItemsControl in Canvas to bind the grid line onto it this.itemsControl = new ItemsControl(); FrameworkElementFactory factoryPanel = new FrameworkElementFactory(typeof(Canvas)); factoryPanel.SetValue(StackPanel.IsItemsHostProperty, true); ItemsPanelTemplate template = new ItemsPanelTemplate(); template.VisualTree = factoryPanel; itemsControl.ItemsPanel = template; this.Children.Add(itemsControl); this.Background = Brushes.Transparent; // Styling ((EndlessGridViewModel)this.DataContext).RunCommand.Execute(null); CreateBinding(); }
static ListBox() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(typeof(ListBox))); _dType = DependencyObjectType.FromSystemTypeInternal(typeof(ListBox)); IsTabStopProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(KeyboardNavigationMode.Contained)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once)); IsTextSearchEnabledProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(BooleanBoxes.TrueBox)); ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(VirtualizingStackPanel))); template.Seal(); ItemsPanelProperty.OverrideMetadata(typeof(ListBox), new FrameworkPropertyMetadata(template)); // Need handled events too here because any mouse up should release our mouse capture EventManager.RegisterClassHandler(typeof(ListBox), Mouse.MouseUpEvent, new MouseButtonEventHandler(OnMouseButtonUp), true); EventManager.RegisterClassHandler(typeof(ListBox), Keyboard.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnGotKeyboardFocus)); CommandHelpers.RegisterCommandHandler(typeof(ListBox), ListBox.SelectAllCommand, new ExecutedRoutedEventHandler(OnSelectAll), new CanExecuteRoutedEventHandler(OnQueryStatusSelectAll), KeyGesture.CreateFromResourceStrings(SR.Get(SRID.ListBoxSelectAllKey), SR.Get(SRID.ListBoxSelectAllKeyDisplayString))); }
// 생성자에서 그리드 박스 생성. public ColorGridBox() { FrameworkElementFactory factoryUnigrid = new FrameworkElementFactory(typeof(UniformGrid)); factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8); ItemsPanel = new ItemsPanelTemplate(factoryUnigrid); foreach (string strColor in strColors) { // Fill 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); ToolTip tip = new ToolTip(); tip.Content = strColor; rect.ToolTip = tip; } SelectedValuePath = "Fill"; }
private static ItemsPanelTemplate GetDefaultItemsPanelTemplate() { var root = new FrameworkElementFactory(typeof(ViewportHostPanel)); ItemsPanelTemplate template = new ItemsPanelTemplate(root); template.Seal(); return template; }
/// <summary>Called when the control template changes.</summary> /// <param name="oldTemplate">Value of the old template.</param> /// <param name="newTemplate">Value of the new template.</param> // Token: 0x0600510B RID: 20747 RVA: 0x00002137 File Offset: 0x00000337 protected virtual void OnTemplateChanged(ItemsPanelTemplate oldTemplate, ItemsPanelTemplate newTemplate) { }
protected virtual void OnItemsPanelChanged (ItemsPanelTemplate oldItemsPanel, ItemsPanelTemplate newItemsPanel) { //WDTDH }
protected virtual new void OnItemsPanelChanged(ItemsPanelTemplate oldItemsPanel, ItemsPanelTemplate newItemsPanel) { }
public GMapControl() { if(!DesignModeInConstruct) { #region -- templates -- #region -- xaml -- // <ItemsControl Name="figures"> // <ItemsControl.ItemTemplate> // <DataTemplate> // <ContentPresenter Content="{Binding Path=Shape}" /> // </DataTemplate> // </ItemsControl.ItemTemplate> // <ItemsControl.ItemsPanel> // <ItemsPanelTemplate> // <Canvas /> // </ItemsPanelTemplate> // </ItemsControl.ItemsPanel> // <ItemsControl.ItemContainerStyle> // <Style> // <Setter Property="Canvas.Left" Value="{Binding Path=LocalPositionX}"/> // <Setter Property="Canvas.Top" Value="{Binding Path=LocalPositionY}"/> // </Style> // </ItemsControl.ItemContainerStyle> //</ItemsControl> #endregion if(DataTemplateInstance == null) { DataTemplateInstance = new DataTemplate(typeof(GMapMarker)); { FrameworkElementFactory fef = new FrameworkElementFactory(typeof(ContentPresenter)); fef.SetBinding(ContentPresenter.ContentProperty, new Binding("Shape")); DataTemplateInstance.VisualTree = fef; } } ItemTemplate = DataTemplateInstance; if(ItemsPanelTemplateInstance == null) { var factoryPanel = new FrameworkElementFactory(typeof(Canvas)); { factoryPanel.SetValue(Canvas.IsItemsHostProperty, true); ItemsPanelTemplateInstance = new ItemsPanelTemplate(); { ItemsPanelTemplateInstance.VisualTree = factoryPanel; } } } ItemsPanel = ItemsPanelTemplateInstance; if(StyleInstance == null) { StyleInstance = new Style(); { StyleInstance.Setters.Add(new Setter(Canvas.LeftProperty, new Binding("LocalPositionX"))); StyleInstance.Setters.Add(new Setter(Canvas.TopProperty, new Binding("LocalPositionY"))); StyleInstance.Setters.Add(new Setter(Canvas.ZIndexProperty, new Binding("ZIndex"))); } } ItemContainerStyle = StyleInstance; #endregion ClipToBounds = true; SnapsToDevicePixels = true; Core.SystemType = "WindowsPresentation"; Core.RenderMode = GMap.NET.RenderMode.WPF; Core.OnMapZoomChanged += new MapZoomChanged(ForceUpdateOverlays); Loaded += new RoutedEventHandler(GMapControl_Loaded); Dispatcher.ShutdownStarted += new EventHandler(Dispatcher_ShutdownStarted); SizeChanged += new SizeChangedEventHandler(GMapControl_SizeChanged); // by default its internal property, feel free to use your own if(ItemsSource == null) { ItemsSource = Markers; } Core.Zoom = (int)((double)ZoomProperty.DefaultMetadata.DefaultValue); } }