![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | xaml resourcedictionary I am new to Xaml and want to create a simple Xaml file that can be used on a windows or web app. I created a xaml file with a ResourceDictionary tag as a root which contains a StackPanel tag that contains a button and a textbox. I want to fill the content of the Page and the Window elements with the same StackPanel in the ResourceDictionary Xaml file so both apps have the same textbox and button. I have the following code in the Window constructor: ResourceDictionary resDict = new ResourceDictionary(); Uri uriRes = new Uri("MyXaml.xaml", UriKind.Relative); resDict.Source = uriRes; foreach (object objResource in resDict.Values) { StackPanel stk = (StackPanel)objResource; this.Content = stk; } This puts the textbox and button on the form, but I am unable to reference either object in the code because it complains if I put the Name attribute in the textbox or button tags in the ResourceDictionary Xaml file. I could get to them with the code ((TextBox)((StackPanel)this.Content).Children[1]) but this is not a generic solution and I won't be able to respond to their events. How can I achieve a generic and reusable Xaml definition for a simple form? Is this the right way or do I need to do something else. Is it possible to achieve this with Xaml? Please help. Thanks, |
My System Specs![]() |
| Thread Tools | |
| |