private static ItemsPanelTemplate GetDefaultItemsPanel() { ItemsPanelTemplate template = new ItemsPanelTemplate() { _methodToInstantiateFrameworkTemplate = (Control templateOwner) => { return(new TemplateInstance() { // Default items panel. // Note: the parameter templateOwner is made necessary // for the ControlTemplates but can be kept null for DataTemplates. TemplateContent = new StackPanel() }); } }; template.Seal(); // Note: We seal the template in order to avoid letting the user modify the // default template itself since it is the same instance that is used as // the default value for all ItemsControls. // This would bring issues such as a user modifying the default template // for one element then modifying it again for another one and both would // have the last one's template. return(template); }
public ColorGridBox() { // ItemsPanel template FrameworkElementFactory factoryUnigrid = new FrameworkElementFactory(typeof(UniformGrid)); factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8); ItemsPanel = new ItemsPanelTemplate(factoryUnigrid); // fill the list foreach (string strColor in strColors) { // rect Rectangle rect = new Rectangle() { Width = 12, Height = 12, Margin = new Thickness(4), Fill = (Brush)typeof(Brushes).GetProperty(strColor).GetValue(null, null) }; Items.Add(rect); // tooltip ToolTip tip = new ToolTip() { Content = strColor }; rect.ToolTip = tip; } SelectedValuePath = "Fill"; }
private static void ItemsPanelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { AdaptiveCollectionView obj = (AdaptiveCollectionView)d; ItemsPanelTemplate value = (ItemsPanelTemplate)e.NewValue; obj.SetBaseItemsPanel(value); }
public ColorWheel() { // Defining template of ItemsPanel FrameworkElementFactory factoryRadialPanel = new FrameworkElementFactory(typeof(RadialPanel)); ItemsPanel = new ItemsPanelTemplate(factoryRadialPanel); // Creation DataTemplate object for options DataTemplate template = new DataTemplate(typeof(Brush)); ItemTemplate = template; // Creation 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("")); // Setting elRectangle as VisualTree node template.VisualTree = elRectangle; // Filling list ListBox PropertyInfo[] prps = typeof(Brushes).GetProperties(); foreach (PropertyInfo prop in prps) { Items.Add((Brush)prop.GetValue(null, null)); } }
public void tableView() { GridViewColumn col1 = new GridViewColumn(); col1.Header = "Название"; col1.DisplayMemberBinding = new System.Windows.Data.Binding("Name"); GridViewColumn col2 = new GridViewColumn(); col2.Header = "Стоимость"; col2.DisplayMemberBinding = new System.Windows.Data.Binding("Price"); GridViewColumn col3 = new GridViewColumn(); col3.Header = "Вес"; col3.DisplayMemberBinding = new System.Windows.Data.Binding("Weight"); GridView GV = new GridView(); GV.Columns.Add(col1); GV.Columns.Add(col2); GV.Columns.Add(col3); this.listView.View = GV; ItemsPanelTemplate IPT = new ItemsPanelTemplate(); FrameworkElementFactory FEFUG = new FrameworkElementFactory(typeof(StackPanel)); FEFUG.SetValue(StackPanel.OrientationProperty, System.Windows.Controls.Orientation.Vertical); IPT.VisualTree = FEFUG; this.listView.ItemsPanel = IPT; }
private static void InitPanel() { var itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(FlyoutPanel))); itemsPanelTemplate.Seal(); ItemsPanelProperty.OverrideMetadata(typeof(AutoHideGroupControl), new FrameworkPropertyMetadata(itemsPanelTemplate)); }
public void TestItemsPanel() { var lb = ListBox(); var template = new ItemsPanelTemplate(); lb.ItemsPanel(template).ItemsPanel.Should().Be(template); }
private static FrameworkPropertyMetadata ItemsPanelMetadata() { var defaultPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(TimelineCompactPanel))); var md = new FrameworkPropertyMetadata(defaultPanelTemplate); return(md); }
public ConnectionItemsControl() { ItemsPanel = new ItemsPanelTemplate() { VisualTree = new FrameworkElementFactory(typeof(Canvas)) }; }
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; // Call ViewModel to compute data required for View ((EndlessGridViewModel)this.DataContext).InitializeOnce(); CreateBinding(); }
static object GetDefaultItemsPanelTemplate() { ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(UniformGrid))); itemsPanelTemplate.Seal(); return(itemsPanelTemplate); }
static BottomScrolledItemsControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(BottomScrolledItemsControl), new FrameworkPropertyMetadata(typeof(BottomScrolledItemsControl))); ItemsPanelTemplate itemsPanel = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(VirtualizingStackPanel))); ItemsPanelProperty.OverrideMetadata(typeof(BottomScrolledItemsControl), new FrameworkPropertyMetadata(itemsPanel)); }
public ColorGridBox() { // Definition of template of ItemsPanel FrameworkElementFactory factoryUnigrid = new FrameworkElementFactory(typeof(UniformGrid)); factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8); ItemsPanel = new ItemsPanelTemplate(factoryUnigrid); // Filling list foreach (string strColor in strColors) { // Creation Rectangle object & adding it in 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); // Creation ToolTip object for Rectangle ToolTip tip = new ToolTip(); tip.Content = strColor; rect.ToolTip = tip; } // В качестве SelectedValue выбирается // свойство Fill объекта Rectangle SelectedValuePath = "Fill"; }
private void OnCommandsPanelChanged(ItemsPanelTemplate current) { if (!IsTemplateApplied) { return; } /*if (null != commandsPanel) * { * var panel = commandsPanel.Template; * * buttonsGrid.Children.Remove(panel); * panel.ClearValue(Grid.ColumnProperty); * } * * commandsPanel = current; * * if (null != commandsPanel) * { * var panel = commandsPanel.Template; * * Grid.SetColumn(panel, 1); * buttonsGrid.Children.Add(panel); * // panel.HorizontalAlignment = HorizontalAlignment.Right; * // panel.VerticalAlignment = VerticalAlignment.Stretch; * }*/ }
static void OnItemsPanel_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsControl element = (ItemsControl)d; ItemsPanelTemplate newTemplate = (ItemsPanelTemplate)e.NewValue; element.UpdateItemsPanel(newTemplate); }
public static FrameworkElement Render(AdaptiveImageSet imageSet, AdaptiveRenderContext context) { var uiImageSet = new ListBox(); uiImageSet.BorderThickness = new Thickness(0); uiImageSet.Background = new SolidColorBrush(Colors.Transparent); ScrollViewer.SetHorizontalScrollBarVisibility(uiImageSet, ScrollBarVisibility.Disabled); var itemsPanelTemplate = new ItemsPanelTemplate(); var factory = new FrameworkElementFactory(typeof(WrapPanel)); // factory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); itemsPanelTemplate.VisualTree = factory; uiImageSet.ItemsPanel = itemsPanelTemplate; uiImageSet.Style = context.GetStyle("Adaptive.ImageSet"); foreach (var image in imageSet.Images) { if (image.Size == AdaptiveImageSize.Auto) { if (imageSet.ImageSize != AdaptiveImageSize.Auto) { image.Size = imageSet.ImageSize; } else { image.Size = context.Config.ImageSet.ImageSize; } } var uiImage = context.Render(image); uiImageSet.Add(uiImage); } return(uiImageSet); }
private static ItemsPanelTemplate GetDefaultItemsPanelTemplate() { ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(DrawingCanvas))); template.Seal(); return(template); }
public VirtualizingItemsControl() { ItemsPanel = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(VirtualizingStackPanel))); string template = @" <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <Border BorderThickness='{TemplateBinding Border.BorderThickness}' Padding='{TemplateBinding Control.Padding}' BorderBrush='{TemplateBinding Border.BorderBrush}' Background='{TemplateBinding Panel.Background}' SnapsToDevicePixels='True'> <ScrollViewer Padding='{TemplateBinding Control.Padding}' Focusable='False'> <ItemsPresenter SnapsToDevicePixels='{TemplateBinding UIElement.SnapsToDevicePixels}'/> </ScrollViewer> </Border> </ControlTemplate>"; Template = (ControlTemplate)XamlReader.Parse(template); ScrollViewer.SetCanContentScroll(this, true); ScrollViewer.SetVerticalScrollBarVisibility(this, ScrollBarVisibility.Auto); ScrollViewer.SetHorizontalScrollBarVisibility(this, ScrollBarVisibility.Auto); VirtualizingPanel.SetCacheLengthUnit(this, VirtualizationCacheLengthUnit.Page); VirtualizingPanel.SetCacheLength(this, new VirtualizationCacheLength(1)); VirtualizingPanel.SetIsVirtualizingWhenGrouping(this, true); }
public ColorGridBox() { // ItemsPanel template을 정의 FrameworkElementFactory factoryUnigrid = new FrameworkElementFactory(typeof(UniformGrid)); factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8); // ListBox의 ItemsPanel 속성에 UniformGrid로 설정 ItemsPanel = new ItemsPanelTemplate(factoryUnigrid); // ListBox에 아이템을 넣는다. foreach (string strColor in strColors) { // 직사각형(Rectangle)을 생성하고 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); // 직사각형(Rectangle에 툴팁 추가) ToolTip tip = new ToolTip(); tip.Content = strColor; rect.ToolTip = tip; } // Indicate that SelectedValue is Fill property of Rectangle item. SelectedValuePath = "Fill"; }
public ColorGridBox() { //Определение шаблона и его включение в ListBox FrameworkElementFactory factoryUnigrid = new FrameworkElementFactory(typeof(UniformGrid)); factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8); ItemsPanel = new ItemsPanelTemplate(factoryUnigrid); //заполнение списка foreach (string strColor in strColors) { //Создание объекта Rectangle и включение его в 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); //Создание объекта ToolTip для Rectangle ToolTip tip = new ToolTip(); tip.Content = strColor; rect.ToolTip = tip; } //В качестве выбранного значения выбирается свойствo fill объекта Rectangle SelectedValuePath = "Fill"; }
public void Tiling(e_bool e = e_bool.manual) { var a = new ObservableCollection <ChartData>(vm.Vms); vm.Vms.Clear(); if ((istile == true && e == e_bool.manual) || e == e_bool.True) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(StackPanel)); ItemsPanelTemplate template = new ItemsPanelTemplate(); template.VisualTree = factory; listBox.ItemsPanel = template; istile = false; } else if ((istile == false && e == e_bool.manual) || e == e_bool.False) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(WrapPanel)); factory.SetValue(WrapPanel.OrientationProperty, Orientation.Horizontal); ItemsPanelTemplate template = new ItemsPanelTemplate(); template.VisualTree = factory; listBox.ItemsPanel = template; istile = true; } foreach (var item in a) { item.ReFresh(); vm.Vms.Add(item); } }
static ItemsPanelTemplate GetDefaultItemsPanelTemplate() { ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(StackPanel))); template.Seal(); return(template); }
/// <summary> /// Constructor for ColorPickerControl, which is a ListBox subclass /// </summary> public ColorPickerControl() { // Define a template for the Items, used the lazy FrameworkElementFactory // method FrameworkElementFactory fGrid = new FrameworkElementFactory(typeof(System.Windows.Controls.Primitives.UniformGrid)); fGrid.SetValue(System.Windows.Controls.Primitives.UniformGrid.ColumnsProperty, 10); //update the ListBox ItemsPanel with the new ItemsPanelTemplate just created ItemsPanel = new ItemsPanelTemplate(fGrid); // Create individual items foreach (string clr in _sColors) { // Creat bounding rectnagle for items data Rectangle rItem = new Rectangle(); rItem.Width = 10; rItem.Height = 10; rItem.Margin = new Thickness(1); rItem.Fill = (Brush)typeof(Brushes).GetProperty(clr).GetValue(null, null); //add rectangle to ListBox Items Items.Add(rItem); //add a tooltip ToolTip t = new ToolTip(); t.Content = clr; rItem.ToolTip = t; } //Indicate that SelectedValue is Fill property of Rectangle item. //Kind of like an XPath query, this is the string name of the property //to use as the the selected item value from the actual item data. The item //data being a Rectangle in this case SelectedValuePath = "Fill"; }
private void CreateSlider() { flipViewWrap = new FlipView(); WebView[][] webViews = new WebView[urls.Length][]; FlipView[] flipViews = new FlipView[urls.Length]; for (int i = 0; i < urls.Length; i++) { flipViews[i] = new FlipView(); webViews[i] = new WebView[urls[i].Length]; for (int j = 0; j < urls[i].Length; j++) { webViews[i][j] = new WebView(); try { if (String.IsNullOrEmpty(urls[i][j])) { throw new Exception(); } if (urls[i][j].Equals("about:blank")) { throw new Exception(); } if (!urls[i][j].StartsWith("http://") && !urls[i][j].StartsWith("https://")) { urls[i][j] = "http://" + urls[i][j]; } Uri targetUri; if (Uri.TryCreate(urls[i][j], UriKind.Absolute, out targetUri)) // && (targetUri.Scheme == Uri.UriSchemeHttp)) { webViews[i][j].Navigate(targetUri); } else { throw new Exception(); } } catch (Exception ex) { webViews[i][j].NavigateToString("<html><body><h2>Can't download " + urls[i][j] + "</h2></body></html>"); System.Diagnostics.Debug.Write(ex.ToString()); } } var itemsPanelTemplate = new ItemsPanelTemplate(); itemsPanelTemplate.SetValue(VirtualizingStackPanel.OrientationProperty, Orientation.Vertical); flipViews[i].ItemsPanel = itemsPanelTemplate; flipViews[i].ItemsSource = webViews[i]; } flipViewWrap.ItemsSource = flipViews; sliderWrap.Children.Add(flipViewWrap); }
public static ItemsPanelTemplate CreateItemsPanelTemplate <T>() where T : Panel { ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(T))); template.Seal(); return(template); }
public ColorWheel() { // Define the ItemsPanel template var factoryRadialPanel = new FrameworkElementFactory(typeof(RadialPanel)); ItemsPanel = new ItemsPanelTemplate(factoryRadialPanel); // Create the DataTemplate for the items var template = new DataTemplate(typeof(Brush)); ItemTemplate = template; // Create a FrameworkElementFactory based on Rectangle with specific properties (like width, margin, etc.) var 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 var props = typeof(Brushes).GetProperties(); // Add color selection into our panel foreach (var prop in props) { Items.Add((Brush)prop.GetValue(null, null)); } }
public ColorGridBox() { FrameworkElementFactory factoryUnigrid = new FrameworkElementFactory(typeof(UniformGrid)); factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8); ItemsPanel = new ItemsPanelTemplate(factoryUnigrid); foreach (string strColor in strColors) { 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"; }
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)); }
protected virtual void UpdateItemsPanel(ItemsPanelTemplate newTemplate) { if (this.ItemsPresenter != null) { this.ItemsPresenter.Template = newTemplate; } }
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"; }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors static StatusBar() { DefaultStyleKeyProperty.OverrideMetadata(typeof(StatusBar), new FrameworkPropertyMetadata(typeof(StatusBar))); _dType = DependencyObjectType.FromSystemTypeInternal(typeof(StatusBar)); IsTabStopProperty.OverrideMetadata(typeof(StatusBar), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(DockPanel))); template.Seal(); ItemsPanelProperty.OverrideMetadata(typeof(StatusBar), new FrameworkPropertyMetadata(template)); }
private static ItemsPanelTemplate CreateDefaultItemsPanelTemplate() { var panelTemplateFactory = new FrameworkElementFactory(typeof (StackPanel)); panelTemplateFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); var res = new ItemsPanelTemplate() { VisualTree = panelTemplateFactory }; return res; }
protected virtual void OnTemplateChanged(ItemsPanelTemplate oldTemplate, ItemsPanelTemplate newTemplate) { }