protected override void OnNavigatedTo(NavigationEventArgs e) { this.Items = new ObservableCollection<object>(PhotosDataSource.GetItems()); this.ItemTemplate = Resources["PhotoTemplate"] as DataTemplate; base.OnNavigatedTo(e); }
protected override void OnNavigatedTo(NavigationEventArgs e) { this.Refresh(); this.ItemTemplate = Resources["PhotoTemplate"] as DataTemplate; base.OnNavigatedTo(e); }
public ListBoxHandler() { Control = new swc.ListBox(); Control.HorizontalAlignment = sw.HorizontalAlignment.Stretch; //Control.DisplayMemberPath = "Text"; var template = new sw.DataTemplate(typeof(IListItem)); template.VisualTree = WpfListItemHelper.ItemTemplate(false); Control.ItemTemplate = template; Control.SelectionChanged += delegate { Widget.OnSelectedIndexChanged(EventArgs.Empty); }; Control.MouseDoubleClick += delegate { if (SelectedIndex >= 0) { Widget.OnActivated(EventArgs.Empty); } }; Control.KeyDown += (sender, e) => { if (e.Key == sw.Input.Key.Return) { if (SelectedIndex >= 0) { Widget.OnActivated(EventArgs.Empty); e.Handled = true; } } }; }
public MainPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; this.footerTemplate = listHostel.FooterTemplate; detailsControl.SubmitClicked += detailsControl_SubmitClicked; detailsControl.CancelClicked += detailsControl_CancelClicked; }
public ContentPresenterCache(Canvas canvas, DataTemplate dataTemplate) { _canvas = canvas; _dataTemplate = dataTemplate; for (int i = 0; i < 10; i++) { _cpList.Enqueue(GenerateNewPresenter()); } }
void UpdateContent(Cell newCell) { Windows.UI.Xaml.DataTemplate dt = GetTemplate(newCell); if (dt != _currentTemplate || Content == null) { _currentTemplate = dt; Content = dt.LoadContent(); } ((FrameworkElement)Content).DataContext = newCell; }
/// <summary> /// Provides derived classes an opportunity to handle changes /// to the EditableContentTemplate property. /// </summary> /// <param name="oldEditableContentTemplate">The old EditableContentTemplate value</param> /// <param name="newEditableContentTemplate">The new EditableContentTemplate value</param> private void OnEditableContentTemplateChanged( DataTemplate oldEditableContentTemplate, DataTemplate newEditableContentTemplate) { if (this.IsSelected) { _changingTemplates = true; this.ContentTemplate = newEditableContentTemplate; _changingTemplates = false; } _isEditable = true; }
protected override void OnNavigatedTo(NavigationEventArgs e) { var items = PhotosDataSource.GetItems(); this.NatureItems = new ObservableCollection<object>(items.Where(x => x.Category == "Nature")); this.AnimalItems = new ObservableCollection<object>(items.Where(x => x.Category == "Animal")); this.CityItems = new ObservableCollection<object>(items.Where(x => x.Category == "City")); this.MotorItems = new ObservableCollection<object>(items.Where(x => x.Category == "Motor")); this.ItemTemplate = Resources["PhotoItemTemplate"] as DataTemplate; base.OnNavigatedTo(e); }
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { Book b = item as Book; if (b == null) return _selectedTemplate; switch (b.Publisher) { case "Wrox Press": _selectedTemplate = WroxBookTemplate; break; default: _selectedTemplate = DefaultBookTemplate; break; } return _selectedTemplate; }
private void Element_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "IsHidden") { if ((Element as MyTabbedPage).IsHidden) { Windows.UI.Xaml.DataTemplate template = App.Current.Resources["MyDataTemplate"] as Windows.UI.Xaml.DataTemplate; Control.HeaderTemplate = template; Control.IsEnabled = true; } else { Control.HeaderTemplate = originalTemplate; Control.IsEnabled = true; } } }
private static void ItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsHub hub = d as ItemsHub; if (hub != null) { Windows.UI.Xaml.DataTemplate template = e.NewValue as Windows.UI.Xaml.DataTemplate; if (template != null) { // Apply template foreach (var section in hub.Sections) { section.ContentTemplate = template; } } } }
private void InitPivot() { var binding = new Binding { Source = ViewModel, Path = new PropertyPath("CurrentRecords") }; _itemTemplate = Resources["ListViewTemplate"] as DataTemplate; foreach (var day in Enum.GetNames(typeof(DayOfWeek))) { var listView = new ListView { ItemTemplate = _itemTemplate, IsItemClickEnabled = true }; listView.ItemClick += ItemView_ItemClick; listView.SetBinding(ItemsControl.ItemsSourceProperty, binding); var pivotItem = new PivotItem { Header = day, Name = day, Content = listView }; pivot.Items.Add(pivotItem); } }
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 Windows.UI.Xaml.Data.Binding("Text") { Source = this, Mode = BindingMode.TwoWay #if TODO_XAML , UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged #endif }); var editTemplate = new DataTemplate { VisualTree = textBox }; var textBlock = new FrameworkElementFactory(typeof(TextBlock)); textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2)); textBlock.AddHandler(UIElement.PointerPressedEvent, (s, e) => { PointerPoint pt; if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && (pt = e.GetCurrentPoint(textBlock) != null) && #if TODO_XAML e.ClickCount >= 2 && #endif pt.Properties.IsLeftButtonPressed) { IsInEditMode = true; e.Handled = true; } }); textBlock.SetBinding(TextBlock.TextProperty, new Windows.UI.Xaml.Data.Binding("Text") { Source = this }); var viewTemplate = new DataTemplate { VisualTree = textBlock }; var style = new Windows.UI.Xaml.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; }
private void pageRoot_SizeChanged(object sender, SizeChangedEventArgs e) { var currentFrame = Window.Current.Content as Frame; var currentPage = currentFrame.Content as Page; var newViewState = Windows.UI.ViewManagement.ApplicationView.Value; if (newViewState == Windows.UI.ViewManagement.ApplicationViewState.Snapped) { Windows.UI.Xaml.DataTemplate Temp = currentPage.Resources["BotonesSnappedItemTemplate"] as Windows.UI.Xaml.DataTemplate; GridBotones.ItemTemplate = Temp; GridBotones.Margin = new Windows.UI.Xaml.Thickness(25, 0, 20, 100); } else { Windows.UI.Xaml.DataTemplate Temp = currentPage.Resources["BotonesItemTemplate"] as Windows.UI.Xaml.DataTemplate; GridBotones.ItemTemplate = Temp; GridBotones.Margin = new Windows.UI.Xaml.Thickness(120, 0, 40, 100); } }
protected override void OnApplicationViewStateChanged() { object template; string templateName; // ContentTemplate templateName = ViewState != ApplicationViewState.Snapped ? "PersistentObjectTemplate" : "PersistentObjectSnappedTemplate"; Application.Current.Resources.TryGetValue(templateName + "." + PersistentObject.Type, out template); if (template == null) Application.Current.Resources.TryGetValue(templateName, out template); if (template == null || template != ContentTemplate) ContentTemplate = (DataTemplate)template ?? EmptyTemplate; // Template templateName = ViewState != ApplicationViewState.Snapped ? "PersistentObjectPage" : "PersistentObjectSnappedPage"; Application.Current.Resources.TryGetValue(templateName + "." + PersistentObject.Type, out template); if (template == null) Application.Current.Resources.TryGetValue(templateName, out template); if (template == null || template != Template) Template = (DataTemplate)template ?? EmptyTemplate; }
private static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsHub hub = d as ItemsHub; if (hub != null) { IEnumerable items = e.NewValue as IEnumerable; if (items != null) { // hub.Sections.Clear(); var sec = hub.Sections.Where(h => (string)h.Tag == "dyn").ToList(); foreach (var hubSection in sec) { hub.Sections.Remove(hubSection); } foreach (var item in items) { HubSection section = new HubSection(); section.Tag = "dyn"; section.DataContext = item; section.HeaderTemplate = hub.ItemHeaderTemplate; Windows.UI.Xaml.DataTemplate template = hub.ItemTemplate; section.ContentTemplate = template; //hub.Sections.Add(section); hub.Sections.Insert(0, section); } } } }
private void SetHeaderTemplate(DataTemplate headerTemplate) { foreach (AccordionItem item in base.Children) { item.HeaderTemplate = headerTemplate; } }
/// <summary> /// Provides derived classes an opportunity to handle changes /// to the EditableItemTemplate property. /// </summary> /// <param name="oldEditableItemTemplate">The old EditableItemTemplate value</param> /// <param name="newEditableItemTemplate">The new EditableItemTemplate value</param> private void OnEditableItemTemplateChanged( DataTemplate oldEditableItemTemplate, DataTemplate newEditableItemTemplate) { }
/// <summary> /// Builds the visual tree for the /// <see cref="T:WinRTXamlToolkit.Controls.Primitives.CalendarItem" /> /// when a new template is applied. /// </summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); HeaderButton = GetTemplateChild(ElementHeaderButton) as Button; PreviousButton = GetTemplateChild(ElementPreviousButton) as Button; NextButton = GetTemplateChild(ElementNextButton) as Button; _dayTitleTemplate = GetTemplateChild(ElementDayTitleTemplate) as DataTemplate; MonthView = GetTemplateChild(ElementMonthView) as Grid; YearView = GetTemplateChild(ElementYearView) as Grid; _disabledVisual = GetTemplateChild(ElementDisabledVisual) as FrameworkElement; if (Owner != null) { UpdateDisabledGrid(Owner.IsEnabled); } PopulateGrids(); if (MonthView != null && YearView != null) { if (Owner != null) { Owner.SelectedMonth = Owner.DisplayDateInternal; Owner.SelectedYear = Owner.DisplayDateInternal; if (Owner.DisplayMode == CalendarMode.Year) { UpdateYearMode(); } else if (Owner.DisplayMode == CalendarMode.Decade) { UpdateDecadeMode(); } if (Owner.DisplayMode == CalendarMode.Month) { UpdateMonthMode(); MonthView.Visibility = Visibility.Visible; YearView.Visibility = Visibility.Collapsed; } else { YearView.Visibility = Visibility.Visible; MonthView.Visibility = Visibility.Collapsed; } } else { UpdateMonthMode(); MonthView.Visibility = Visibility.Visible; YearView.Visibility = Visibility.Collapsed; } } }
private void SetItemTemplate(DataTemplate itemTemplate) { foreach (ContentControl item in base.Children) { item.ContentTemplate = itemTemplate; } }
internal void UpdateItemTemplateSelector(DataTemplate itemTemplate) { this.ItemTemplate = itemTemplate; }
protected override void OnContentTemplateChanged(DataTemplate oldContentTemplate, DataTemplate newContentTemplate) { base.OnContentTemplateChanged(oldContentTemplate, newContentTemplate); if (!_changingTemplates) { SlimContentTemplate = this.ContentTemplate; } }
public static void SetSectionTemplate(UIElement element, DataTemplate value) { element.SetValue(SectionTemplateProperty, value); }
private ListViewItem SwitchToItemState(object dataContext, DataTemplate template) { var item = WifiListView.ContainerFromItem(dataContext) as ListViewItem; item.ContentTemplate = template; return item; }
private void BuildHubControl() { HubControl.Sections.Clear(); var templateSelector = new ItemsShowcaseViewItemGroupDataTemplateSelector(); foreach(var itemGroup in ((ItemsShowcaseViewModel)DataContext).ItemGroups) { var hubSection = new HubSection(); var dataTemplate = new DataTemplate(); hubSection.Header = itemGroup.Key; hubSection.ContentTemplate = templateSelector.SelectTemplate(itemGroup, hubSection); hubSection.DataContext = itemGroup; HubControl.Sections.Add(hubSection); } }
public static void SetHeaderTemplate(UIElement element, DataTemplate value) { element.SetValue(HeaderTemplateProperty, value); }
public static void SetItemTemplate(VariableSizedWrapGrid obj, DataTemplate value) { obj.SetValue(ItemTemplateProperty, value); }
public ShellFlyoutTemplateSelector() { BaseShellItemTemplate = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["ShellFlyoutBaseShellItemTemplate"]; MenuItemTemplate = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["ShellFlyoutMenuItemTemplate"]; SeperatorTemplate = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["ShellFlyoutSeperatorTemplate"]; }
protected override void OnApplicationViewStateChanged() { object template; string templateName; // ContentTemplate templateName = ViewState != ApplicationViewState.Snapped ? "QueryTemplate" : "QuerySnappedTemplate"; Application.Current.Resources.TryGetValue(templateName + "." + Query.PersistentObject.Type, out template); if (template == null) Application.Current.Resources.TryGetValue(templateName, out template); if (template == null || template != ContentTemplate) ContentTemplate = (DataTemplate)template ?? EmptyTemplate; // Template templateName = ViewState != ApplicationViewState.Snapped ? "QueryPage" : "QuerySnappedPage"; Application.Current.Resources.TryGetValue(templateName + "." + Query.PersistentObject.Type, out template); if (template == null) Application.Current.Resources.TryGetValue(templateName, out template); if (template == null || template != Template) Template = (DataTemplate)template ?? EmptyTemplate; // QueryItemTemplate if (!Application.Current.Resources.TryGetValue("QueryItemTemplate." + Query.PersistentObject.Type, out template)) template = Application.Current.Resources["QueryItemTemplate.Default"]; if (template == null || template != QueryItemTemplate) QueryItemTemplate = (DataTemplate)template ?? EmptyTemplate; }
void ChangeDataTemplate(DataTemplate dataTemplate) { PoleA.ItemTemplate = dataTemplate; PoleB.ItemTemplate = dataTemplate; PoleC.ItemTemplate = dataTemplate; }
/// <summary> /// Prepares the content control for use in an ItemsControl. /// </summary> /// <param name="this">The this.</param> /// <param name="item">The item.</param> /// <param name="itemTemplate">The item template.</param> /// <param name="itemTemplateSelector">The item template selector.</param> public static void PrepareContentControl( this ContentControl @this, object item, DataTemplate itemTemplate, DataTemplateSelector itemTemplateSelector) { if (item != @this) { if ([email protected](ContentControl.ContentProperty)) { @this.Content = item; } if (itemTemplate != null) { @this.SetValue(ContentControl.ContentTemplateProperty, itemTemplate); } if (itemTemplateSelector != null) { @this.SetValue(ContentControl.ContentTemplateSelectorProperty, itemTemplateSelector); } } }
/// <summary> /// Called when the value of the /// <see cref="P:System.Windows.Controls.HeaderedItemsControl.HeaderTemplate" /> /// property changes. /// </summary> /// <param name="oldHeaderTemplate"> /// The old value of the /// <see cref="P:System.Windows.Controls.HeaderedItemsControl.HeaderTemplate" /> /// property. /// </param> /// <param name="newHeaderTemplate"> /// The new value of the /// <see cref="P:System.Windows.Controls.HeaderedItemsControl.HeaderTemplate" /> /// property. /// </param> protected virtual void OnHeaderTemplateChanged(DataTemplate oldHeaderTemplate, DataTemplate newHeaderTemplate) { }
/// <summary> /// Sets the FadeInTransitioningContentTemplate property. This dependency property /// indicates the value to set the ContentTemplate to between fade out/fade in transitions. /// </summary> public static void SetFadeInTransitioningContentTemplate(DependencyObject d, DataTemplate value) { d.SetValue(FadeInTransitioningContentTemplateProperty, value); }
private void OnHeaderTemplateChanged(DataTemplate oldHeaderTemplate, DataTemplate newHeaderTemplate) { }
public static void SetItemTemplate(DependencyObject obj, DataTemplate value) { obj.SetValue(ItemTemplateProperty, value); }
private ListViewItem SwitchToItemState(object dataContext, DataTemplate template, bool forceUpdate) { if (forceUpdate) { WifiListView.UpdateLayout(); } var item = WifiListView.ContainerFromItem(dataContext) as ListViewItem; if (item != null) { item.ContentTemplate = template; } return item; }
private void AddCachedDataTemplate(string key, DataTemplate dt) { if (!IsCacheEnabled) { return; } this.cachedDataTemplates[key] = dt; }