You could simply define the shared template in your App. Xaml file under the "Resources" element.
Up vote 0 down vote favorite share g+ share fb share tw.
Edited: tried this: public static DataTemplate createDataTemplate() { return (DataTemplate)System.Windows.Markup.XamlReader. Load( @" " ); } when I call this: for (int i=0; I FrameworkTemplate. Template' is set more than once.
Line: 3 Position: 32 why? Windows-phone-7 link|improve this question edited Oct 7 '11 at 11:38 asked Oct 7 '11 at 7:35lacas1,24711243 72% accept rate.
(Please use uppercase i's when referring to yourself rather than some variable. Also please start sentences with uppercase letters. Thanks!
) – Arjan Oct 7 '11 at 11:29.
You could simply define the shared template in your App. Xaml file under the "Resources" element. Define it in App.
Xaml: Access it in code: #region FindResource /// Get a template by the type name of the data. /// The template type. /// The source element.
/// The data type. /// The resource as the type, or null. Private static T FindResource(DependencyObject initial, string key) where T : DependencyObject { DependencyObject current = initial; if (Application.Current.Resources.
Contains(key)) { return (T)Application.Current. Resourceskey; } while (current! = null) { if (current is FrameworkElement) { if ((current as FrameworkElement).Resources.
Contains(key)) { return (T)(current as FrameworkElement). Resourceskey; } } current = VisualTreeHelper. GetParent(current); } return default(T); } #endregion FindResource Use it in your UI: DataTemplate newTemplate = null; string templateKey = "MySharedTemplate"; try { newTemplate = FindResource(this, templateKey); } catch { newTemplate = null; } if (newTemplate!
= null) { this. ListBox1. ItemTemplate = newTemplate; }.
I have a pivot, and a lot of pivotitem on it. Every pivotitem has a listbox, thats why I need to add this lines with code. What alternatives can I do?
In my xaml file there is not any template at the moment... – lacas Oct 7 '11 at 11:17.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.