protected override void OnApplyTemplate() { base.OnApplyTemplate(); _moreButton = GetTemplateChild("MoreButton") as Windows.UI.Xaml.Controls.Button; _primaryItemsControl = GetTemplateChild("PrimaryItemsControl") as Windows.UI.Xaml.Controls.ItemsControl; }
internal async void AttacheHostControl(ItemsControl hostControl) { if (hostControl != null) { var scrollViewer = VisualTreeHelper.FindVisualElement<ScrollViewer>(hostControl); if (scrollViewer == null) { hostControl.Loaded += HostControlOnLoaded; await Task.Run(() => { _waitHandle.WaitOne(1000); }); hostControl.Loaded -= HostControlOnLoaded; await hostControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { scrollViewer = VisualTreeHelper.FindVisualElement<ScrollViewer>(hostControl); }); } await hostControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { AttacheHostControlPrivate(hostControl, scrollViewer); }); } }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _itemContainerList = GetTemplateChild("ItemList") as ItemsControl; _itemContainerList.ItemsSource = _items; }
private static async void Setup(Windows.UI.Xaml.Controls.Flyout m) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var s = GetItemsSource(m); if (s == null) { return; } var t = GetItemTemplate(m); if (t == null) { return; } var c = new Windows.UI.Xaml.Controls.ItemsControl { ItemsSource = s, ItemTemplate = t, }; var n = Windows.UI.Core.CoreDispatcherPriority.Normal; Windows.UI.Core.DispatchedHandler h = () => m.Content = c; await m.Dispatcher.RunAsync(n, h); }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///SearchResultsPage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); pageRoot = (SimpleSearchProvider.Common.LayoutAwarePage) this.FindName("pageRoot"); resultsViewSource = (Windows.UI.Xaml.Data.CollectionViewSource) this.FindName("resultsViewSource"); filtersViewSource = (Windows.UI.Xaml.Data.CollectionViewSource) this.FindName("filtersViewSource"); resultsPanel = (Windows.UI.Xaml.Controls.Grid) this.FindName("resultsPanel"); noResultsTextBlock = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("noResultsTextBlock"); typicalPanel = (Windows.UI.Xaml.Controls.Grid) this.FindName("typicalPanel"); snappedPanel = (Windows.UI.Xaml.Controls.Grid) this.FindName("snappedPanel"); resultsListView = (Windows.UI.Xaml.Controls.ListView) this.FindName("resultsListView"); filtersItemsControl = (Windows.UI.Xaml.Controls.ItemsControl) this.FindName("filtersItemsControl"); resultsGridView = (Windows.UI.Xaml.Controls.GridView) this.FindName("resultsGridView"); backButton = (Windows.UI.Xaml.Controls.Button) this.FindName("backButton"); pageTitle = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("pageTitle"); resultText = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("resultText"); queryText = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("queryText"); ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup) this.FindName("ApplicationViewStates"); ResultStates = (Windows.UI.Xaml.VisualStateGroup) this.FindName("ResultStates"); ResultsFound = (Windows.UI.Xaml.VisualState) this.FindName("ResultsFound"); NoResultsFound = (Windows.UI.Xaml.VisualState) this.FindName("NoResultsFound"); FullScreenLandscape = (Windows.UI.Xaml.VisualState) this.FindName("FullScreenLandscape"); Filled = (Windows.UI.Xaml.VisualState) this.FindName("Filled"); FullScreenPortrait = (Windows.UI.Xaml.VisualState) this.FindName("FullScreenPortrait"); Snapped = (Windows.UI.Xaml.VisualState) this.FindName("Snapped"); }
protected override void OnApplyTemplate() { //if control begins its life as invisible (visibility = collapsed) then OnApplyTemplate is not called BUT becareful because dependency properties OnPropertyChangedEvents do if (_icMain == null) _icMain = GetTemplateChild("icMain") as ItemsControl; base.OnApplyTemplate(); }
internal static void PreparePrepareHeaderedItemsControlContainerForItemOverride(DependencyObject element, object item, ItemsControl parent, Style parentItemContainerStyle) { var headeredItemsControl = element as HeaderedItemsControl; if (headeredItemsControl != null) { PreparePrepareHeaderedItemsControlContainer(headeredItemsControl, item, parent, parentItemContainerStyle); } }
public ToastPromptsHostControl() { _activeItemsControl = new ItemsControl { Background = new SolidColorBrush(Colors.Transparent) }; Children.Add(_activeItemsControl); _timer.Interval = TimeSpan.FromSeconds(1); _timer.Tick += Timer_OnTick; _timer.Start(); _lastUsedInstance = this; //instance is defined in xaml }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); this._modifiersPresenter = this.GetTemplateChild(PART_Modifiers) as ItemsControl; this._keyPresenter = this.GetTemplateChild(PART_KeyIcon) as KeyIcon; this._prompt = this.GetTemplateChild(PART_Prompt) as TextBlock; this.UpdateVisual(); }
public void Go(ref ItemsControl list, string value) { try { load(list, new Uri(value)); } catch { } }
internal void UnattacheHostControl(ItemsControl hostControl) { if (hostControl != null) { var scrollViewer = VisualTreeHelper.FindVisualElement<ScrollViewer>(hostControl); if (scrollViewer != null) { _hostControl = null; scrollViewer.ViewChanged -= OnScrollViewChanged; } } }
public async Task AdapterAssignsARegionThatHasAllViewsActive() { await ExecuteOnUIThread(() => { var control = new ItemsControl(); IRegionAdapter adapter = new ItemsControlRegionAdapter(null); IRegion region = adapter.Initialize(control, "Region1"); Assert.IsNotNull(region); Assert.IsInstanceOfType(region, typeof(AllActiveRegion)); }); }
public async Task AdapterAssociatesItemsControlWithRegion() { await ExecuteOnUIThread(() => { var control = new ItemsControl(); IRegionAdapter adapter = new TestableItemsControlRegionAdapter(); IRegion region = adapter.Initialize(control, "Region1"); Assert.IsNotNull(region); Assert.AreSame(control.ItemsSource, region.Views); }); }
public async Task ShouldMoveAlreadyExistingContentInControlToRegion() { await ExecuteOnUIThread(() => { var control = new ItemsControl(); var view = new object(); control.Items.Add(view); IRegionAdapter adapter = new TestableItemsControlRegionAdapter(); var region = (MockPresentationRegion)adapter.Initialize(control, "Region1"); Assert.AreEqual(1, region.MockViews.Count()); Assert.AreSame(view, region.MockViews.ElementAt(0)); Assert.AreSame(view, control.Items[0]); }); }
private async void AttacheHostControlPrivate(ItemsControl hostControl, ScrollViewer scrollViewer) { if (scrollViewer != null) { IsLoading = true; _hostControl = hostControl; scrollViewer.ViewChanged += OnScrollViewChanged; var data = await FirstRequestData(); await _hostControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { AddDataToHostControl(data); }); IsLoading = false; } else { throw new InvalidOperationException("无法在 ItemControl 中找到 ScrollViewer。"); } }
public static async void OnScheduleChangedStatic(DependencyObject sender, DependencyPropertyChangedEventArgs e) { Func<Color, Color> lighten = clr => Color.FromArgb(clr.A, (byte)(128 + clr.R / 2), (byte)(128 + clr.G / 2), (byte)(128 + clr.B / 2)); Color accentColor = ((Color)App.Current.Resources["SystemColorControlAccentColor"]); ScheduleBrowser typedSender = (ScheduleBrowser)sender; typedSender.MainStackPanel.Children.Clear(); if (typedSender.Schedule == null) return; string lastRoute = null; string lastDestination = null; ItemsControl timesControl = null; foreach (var item in typedSender.Schedule) { if (item.Route != lastRoute || item.Destination != lastDestination) { lastRoute = item.Route; lastDestination = item.Destination; typedSender.MainStackPanel.Children.Add(new TextBlock() { Text = (await Data.GetRoute(lastRoute, typedSender.MasterCancellationTokenSource.Token)).Name + " to " + lastDestination, FontSize = 18, Foreground = new SolidColorBrush(lighten(accentColor)), TextWrapping = TextWrapping.WrapWholeWords }); timesControl = new ItemsControl(); typedSender.MainStackPanel.Children.Add(timesControl); } timesControl.Items.Add(new TextBlock() { Text = item.ScheduledArrivalTime.ToString("h:mm"), HorizontalAlignment = HorizontalAlignment.Center, FontWeight = item.ScheduledArrivalTime.Hour >= 12 ? Windows.UI.Text.FontWeights.Bold : Windows.UI.Text.FontWeights.Normal }); } }
public async Task ControlWithExistingItemSourceThrows() { await ExecuteOnUIThread(() => { var control = new ItemsControl() { ItemsSource = new List<string>() }; IRegionAdapter adapter = new TestableItemsControlRegionAdapter(); Assert.ThrowsException<InvalidOperationException>( () => (MockPresentationRegion)adapter.Initialize(control, "Region1"), "ItemsControl's ItemsSource property is not empty."); }); }
/// <summary> /// Prepare a PrepareHeaderedItemsControlContainer container for an /// item. /// </summary> /// <param name="control">Container to prepare.</param> /// <param name="item">Item to be placed in the container.</param> /// <param name="parentItemsControl">The parent ItemsControl.</param> /// <param name="parentItemContainerStyle"> /// The ItemContainerStyle for the parent ItemsControl. /// </param> private static void PrepareHeaderedItemsControlContainer(HeaderedItemsControl control, object item, ItemsControl parentItemsControl, Style parentItemContainerStyle) { try { if (control != item) { // Copy the ItemsControl properties from parent to child DataTemplate parentItemTemplate = parentItemsControl.ItemTemplate; DataTemplateSelector parentItemTemplateSelector = parentItemsControl.ItemTemplateSelector; if (parentItemTemplateSelector != null) { control.SetValue(HeaderedItemsControl.ItemTemplateSelectorProperty, parentItemTemplateSelector); parentItemTemplate = parentItemTemplateSelector.SelectTemplate(item, control); } else if (parentItemTemplate != null) { control.SetValue(HeaderedItemsControl.ItemTemplateProperty, parentItemTemplate); } if (parentItemContainerStyle != null && HasDefaultValue(control, HeaderedItemsControl.ItemContainerStyleProperty)) { control.SetValue(HeaderedItemsControl.ItemContainerStyleProperty, parentItemContainerStyle); } // Copy the Header properties from parent to child if (control.HeaderIsItem || HasDefaultValue(control, HeaderedItemsControl.HeaderProperty)) { control.Header = item; control.HeaderIsItem = true; } if (parentItemTemplate != null) { control.SetValue(HeaderedItemsControl.HeaderTemplateProperty, parentItemTemplate); } if (parentItemContainerStyle != null && control.Style == null) { control.SetValue(HeaderedItemsControl.StyleProperty, parentItemContainerStyle); } // Note: this is where we would apply the HeaderTemplateSelector // (if implemented) or attempt to lookup the implicit template // for the type of the item if the headerTemplate were null. // Setup a hierarchical template //HierarchicalDataTemplate headerTemplate = parentItemTemplate as HierarchicalDataTemplate; var headerTemplate = parentItemTemplate as DataTemplate; if (headerTemplate != null) { var hierarchy = DataTemplateExtensions.GetHierarchy(headerTemplate); if (hierarchy != null && hierarchy.ItemsSource != null && HasDefaultValue(control, HeaderedItemsControl.ItemsSourceProperty)) { control.SetBinding( HeaderedItemsControl.ItemsSourceProperty, new Binding { Converter = hierarchy.ItemsSource.Converter, ConverterLanguage = hierarchy.ItemsSource.ConverterLanguage, ConverterParameter = hierarchy.ItemsSource.ConverterParameter, Mode = hierarchy.ItemsSource.Mode, //NotifyOnValidationError = headerTemplate.ItemsSource.NotifyOnValidationError, Path = hierarchy.ItemsSource.Path, Source = control.Header, //ElementName = //ValidatesOnExceptions = headerTemplate.ItemsSource.ValidatesOnExceptions }); } if (hierarchy != null && hierarchy.IsItemTemplateSet && control.ItemTemplate == parentItemTemplate) { control.ClearValue(HeaderedItemsControl.ItemTemplateProperty); if (hierarchy.ItemTemplate != null) { control.ItemTemplate = hierarchy.ItemTemplate; } } if (hierarchy != null && hierarchy.IsItemContainerStyleSet && control.ItemContainerStyle == parentItemContainerStyle) { control.ClearValue(HeaderedItemsControl.ItemContainerStyleProperty); if (hierarchy.ItemContainerStyle != null) { control.ItemContainerStyle = hierarchy.ItemContainerStyle; } } } } } catch (COMException ex) { Debug.Assert(false, "Due to some change in the platform in Windows 10 - you now need to set the ItemTemplate before setting the ItemsSource when using a TreeView."); } }
public void Find (ItemsControl ic) { Seek (ic); if (items.Count == 0) Complete (null); }
void AddGenerator (ItemsControl ic) { items.Add (ic.ItemContainerGenerator, ic); ic.ItemContainerGenerator.StatusChanged += HandleStatusChanged; }
public async Task ControlWithExistingBindingOnItemsSourceWithNullValueThrows() { await ExecuteOnUIThread(() => { var control = new ItemsControl(); Binding binding = new Binding { Path = new PropertyPath("Enumerable"), Source = new SimpleModel() { Enumerable = null } }; control.SetBinding(ItemsControl.ItemsSourceProperty, binding); IRegionAdapter adapter = new TestableItemsControlRegionAdapter(); Assert.ThrowsException<InvalidOperationException>( () => (MockPresentationRegion)adapter.Initialize(control, "Region1"), "ItemsControl's ItemsSource property is not empty."); }); }
bool Seek (ItemsControl ic) { if (ic == null || !ic.HasItems) return false; var generator = ic.ItemContainerGenerator; if (generator.Status == GeneratorStatus.ContainersGenerated) { foreach (var item in ic.Items) { var container = generator.ContainerFromItem (item) as TreeViewItem; if (item == SelectedItem && container != null) { Complete (container); return true; } if (Seek (container)) return true; } } else { AddGenerator (ic); } return false; }
static Task<TreeViewItem> FindItem (object dataItem, ItemsControl ic) { var helper = new Helper { SelectedItem = dataItem }; helper.Find (ic); return helper.Task; }
private void CreateItems(ItemsControl container, int numItemsToAdd) { for (var i = 0; i < numItemsToAdd; i++) { int random = rand.Next(0, 17); var item = new Image { Source = new BitmapImage { UriSource = new Uri("ms-appx:///Images/LandscapeImage" + random.ToString() + ".jpg", UriKind.Absolute) }, Width = 200, Height = 134 }; var border = new Border { BorderBrush = new SolidColorBrush(Color.FromArgb(112, 255, 255, 255)), BorderThickness = new Thickness(1), Margin = new Thickness(4), Child = item }; container?.Items?.Add(border); } }
/// <summary> /// Synchronizes the scroll offset of the target ItemsControl to the offset of the source ItemsControl /// such that the first visible item in both controls is the same item. /// </summary> /// <param name="targetItemsControl">The ItemsControl whose scroll offset is to be updated.</param> /// <param name="sourceItemsControl">The ItemsControl whose scroll offset will be matched in the target.</param> /// <param name="throwOnFail">Specifies whether an exception should be thrown on failure.</param> public static void SynchronizeScrollOffset(this ItemsControl targetItemsControl, ItemsControl sourceItemsControl, bool throwOnFail = false) { var firstVisibleIndex = sourceItemsControl.GetFirstVisibleIndex(); if (firstVisibleIndex == -1) { if (throwOnFail) { throw new InvalidOperationException(); } return; } var targetListBox = targetItemsControl as ListBox; if (targetListBox != null) { targetListBox.ScrollIntoView(sourceItemsControl.IndexFromContainer(sourceItemsControl.ContainerFromIndex(firstVisibleIndex))); return; } var targetListViewBase = targetItemsControl as ListViewBase; if (targetListViewBase != null) { targetListViewBase.ScrollIntoView(sourceItemsControl.IndexFromContainer(sourceItemsControl.ContainerFromIndex(firstVisibleIndex)), ScrollIntoViewAlignment.Leading); return; } var scrollViewer = targetItemsControl.GetScrollViewer(); if (scrollViewer != null) { var container = (FrameworkElement)targetItemsControl.ContainerFromIndex(firstVisibleIndex); var position = container.TransformToVisual(scrollViewer).TransformPoint(new Point()); scrollViewer.ChangeView(scrollViewer.HorizontalOffset + position.X, scrollViewer.VerticalOffset + position.Y, null); } }
protected override void OnApplyTemplate() { //if (_bkgLayer == null) _bkgLayer = GetTemplateChild("bkgLayer") as EffectLayer.EffectLayer; if (_icTabList == null) { _icTabList = GetTemplateChild("icTabList") as ItemsControl; if (this.ItemsSource != null) _icTabList.ItemsSource = this.ItemsSource; else _icTabList.ItemsSource = _data; if(this.ItemTemplate!= null) _icTabList.ItemTemplate = this.ItemTemplate; } //if (_bkgLayer != null && _icTabList != null && _icTabList.ActualWidth != 0) _bkgLayer.InitLayer(_icTabList.ActualWidth, _icTabList.ActualHeight); base.OnApplyTemplate(); }
/// <summary> /// Prepare a PrepareHeaderedItemsControlContainer container for an /// item. /// </summary> /// <param name="control">Container to prepare.</param> /// <param name="item">Item to be placed in the container.</param> /// <param name="parentItemsControl">The parent ItemsControl.</param> /// <param name="parentItemContainerStyle"> /// The ItemContainerStyle for the parent ItemsControl. /// </param> private static void PrepareHeaderedItemsControlContainer(HeaderedItemsControl control, object item, ItemsControl parentItemsControl, Style parentItemContainerStyle) { if (control != item) { // Copy the ItemsControl properties from parent to child DataTemplate parentItemTemplate = parentItemsControl.ItemTemplate; if (parentItemTemplate != null) { control.SetValue(HeaderedItemsControl.ItemTemplateProperty, parentItemTemplate); } if (parentItemContainerStyle != null && HasDefaultValue(control, HeaderedItemsControl.ItemContainerStyleProperty)) { control.SetValue(HeaderedItemsControl.ItemContainerStyleProperty, parentItemContainerStyle); } // Copy the Header properties from parent to child if (control.HeaderIsItem || HasDefaultValue(control, HeaderedItemsControl.HeaderProperty)) { control.Header = item; control.HeaderIsItem = true; } if (parentItemTemplate != null) { control.SetValue(HeaderedItemsControl.HeaderTemplateProperty, parentItemTemplate); } if (parentItemContainerStyle != null && control.Style == null) { control.SetValue(HeaderedItemsControl.StyleProperty, parentItemContainerStyle); } // Note: this is where we would apply the HeaderTemplateSelector // (if implemented) or attempt to lookup the implicit template // for the type of the item if the headerTemplate were null. // Setup a hierarchical template HierarchicalDataTemplate headerTemplate = parentItemTemplate as HierarchicalDataTemplate; if (headerTemplate != null) { if (headerTemplate.ItemsSource != null && HasDefaultValue(control, HeaderedItemsControl.ItemsSourceProperty)) { control.SetBinding( HeaderedItemsControl.ItemsSourceProperty, new Binding { Converter = headerTemplate.ItemsSource.Converter, ConverterLanguage = headerTemplate.ItemsSource.ConverterLanguage, ConverterParameter = headerTemplate.ItemsSource.ConverterParameter, Mode = headerTemplate.ItemsSource.Mode, Path = headerTemplate.ItemsSource.Path, Source = control.Header, }); } if (headerTemplate.IsItemTemplateSet && control.ItemTemplate == parentItemTemplate) { control.ClearValue(HeaderedItemsControl.ItemTemplateProperty); if (headerTemplate.ItemTemplate != null) { control.ItemTemplate = headerTemplate.ItemTemplate; } } if (headerTemplate.IsItemContainerStyleSet && control.ItemContainerStyle == parentItemContainerStyle) { control.ClearValue(HeaderedItemsControl.ItemContainerStyleProperty); if (headerTemplate.ItemContainerStyle != null) { control.ItemContainerStyle = headerTemplate.ItemContainerStyle; } } } } }
static TreeViewItem SelectTreeViewItemForBinding (object dataItem, ItemsControl ic) { if (ic == null || dataItem == null || !ic.HasItems) return null; IItemContainerGenerator generator = ic.ItemContainerGenerator; if (ic.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) { foreach (var t in ic.Items) { var tvi = ic.ItemContainerGenerator.ContainerFromItem(t); if (t == dataItem) return tvi as TreeViewItem; var tmp = SelectTreeViewItemForBinding (dataItem, tvi as ItemsControl); if (tmp != null) return tmp; } } else using (generator.StartAt (generator.GeneratorPositionFromIndex (-1), GeneratorDirection.Forward)) { foreach (var t in ic.Items) { bool isNewlyRealized; var tvi = generator.GenerateNext (out isNewlyRealized); if (isNewlyRealized) { generator.PrepareItemContainer (tvi); } if (t == dataItem) return tvi as TreeViewItem; var tmp = SelectTreeViewItemForBinding (dataItem, tvi as ItemsControl); if (tmp != null) return tmp; } } return null; }
public void InitializeComponent() { if (_contentLoaded) return; _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///SearchResultsPage1.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); pageRoot = (Fashionizer2.Common.LayoutAwarePage)this.FindName("pageRoot"); resultsViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("resultsViewSource"); filtersViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("filtersViewSource"); resultsPanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("resultsPanel"); noResultsTextBlock = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("noResultsTextBlock"); typicalPanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("typicalPanel"); snappedPanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("snappedPanel"); resultsListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("resultsListView"); filtersItemsControl = (Windows.UI.Xaml.Controls.ItemsControl)this.FindName("filtersItemsControl"); resultsGridView = (Windows.UI.Xaml.Controls.GridView)this.FindName("resultsGridView"); backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton"); pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle"); resultText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("resultText"); queryText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("queryText"); ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ApplicationViewStates"); ResultStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ResultStates"); ResultsFound = (Windows.UI.Xaml.VisualState)this.FindName("ResultsFound"); NoResultsFound = (Windows.UI.Xaml.VisualState)this.FindName("NoResultsFound"); FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape"); Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled"); FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait"); Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped"); }
internal static void PreparePrepareHeaderedContentControlContainerForItemOverride(HeaderedContentControl element, object item, ItemsControl parent, Style parentItemContainerStyle) { if (element != item) { // We do not have proper access to Visual. // Nor do we keep track of the HeaderIsItem property. if (!(item is UIElement) && HasDefaultValue(element, HeaderProperty)) { element.Header = item; } } }
private static void PreparePrepareHeaderedItemsControlContainer(HeaderedItemsControl control, object item, ItemsControl parentItemsControl, Style parentItemContainerStyle) { if (control != item) { var parentItemTemplate = parentItemsControl.ItemTemplate; if (parentItemTemplate != null) { control.SetValue(ItemTemplateProperty, parentItemTemplate); } if (parentItemContainerStyle != null && HasDefaultValue(control, ItemContainerStyleProperty)) { control.SetValue(ItemContainerStyleProperty, parentItemContainerStyle); } if (control.HeaderIsItem || HasDefaultValue(control, HeaderProperty)) { control.Header = item; control.HeaderIsItem = true; } if (parentItemTemplate != null) { control.SetValue(HeaderTemplateProperty, parentItemTemplate); } if (parentItemContainerStyle != null && control.Style == null) { control.SetValue(StyleProperty, parentItemContainerStyle); } var headerTemplate = parentItemTemplate as HierarchicalDataTemplate; if (headerTemplate != null) { if (headerTemplate.ItemsSource != null && HasDefaultValue(control, ItemsSourceProperty)) { control.SetBinding(ItemsSourceProperty, new Binding { Converter = headerTemplate.ItemsSource.Converter, ConverterLanguage = headerTemplate.ItemsSource.ConverterLanguage, ConverterParameter = headerTemplate.ItemsSource.ConverterParameter, Mode = headerTemplate.ItemsSource.Mode, Path = headerTemplate.ItemsSource.Path, Source = control.Header }); } if (headerTemplate.IsItemTemplateSet && control.ItemTemplate == parentItemTemplate) { control.ClearValue(ItemTemplateProperty); if (headerTemplate.ItemTemplate != null) { control.ItemTemplate = headerTemplate.ItemTemplate; } } if (headerTemplate.IsItemContainerStyleSet && control.ItemContainerStyle == parentItemContainerStyle) { control.ClearValue(ItemContainerStyleProperty); if (headerTemplate.ItemContainerStyle != null) { control.ItemContainerStyle = headerTemplate.ItemContainerStyle; } } } } }
/// <summary> /// Initializes a new instance of the ItemContainerGenerator. /// </summary> /// <param name="control"> /// The ItemsControl being tracked by the ItemContainerGenerator. /// </param> internal ItemsControlHelper(ItemsControl control) { Debug.Assert(control != null, "control cannot be null!"); ItemsControl = control; }
//CalenderView public CalenderView(ItemsControl itemsConrol) { itemsConrol.Height = (BLOCK_HEIGHT + 2 * BLOCK_THICKNESS) * 7 + 30; itemsConrol.Width = (BLOCK_WIDTH + 2 * BLOCK_THICKNESS) * 7; _itemsConrol = itemsConrol; }