Solved

DataTemplate question...

Posted on 2010-08-12
3
311 Views
Last Modified: 2013-11-12
Hello

I have a listbox with my own custom DataTemplate. On it, I have several items which are bound to some class.
One of the items is a StackPanel. Now I have a question about this. I have created a Parser which is converting a string (XML) into a Stackpanel, which is containing several, dynamic, elements. Now I want to set, that the Stackpanel on the DataTemplate is this stackpanel.

Usually, I am binding some attribute (e.g. Text) to a class, sometimes using a Converter. But how can I bind a whole StackPanel to a StackPanel, replacing it?

Or what different approach do I have to take?

Thank¨s a lot
0
Comment
Question by:Ruttensoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
unmeshdave earned 500 total points
ID: 33430748
you can use resource dictionary . In WPF/SL, you can dyanmically add resource dictionary to your program and add dynamic reference to any visual object you want.
like you want to create XML, better to create XAML with resource dictionary definitions inside it, and in your program when you want to add this resource dictionary(i guess you want to use it dynamically), you add this resource dictionary by calling mergedictionaries on current resourcedictionary.
every visual object in resource dictionary will have 'Key' attribute, which you can use to reference.
following link somewhat provides info about what I am saying,
http://blogs.msdn.com/b/wpfsdk/archive/2007/06/08/defining-and-using-shared-resources-in-a-custom-control-library.aspx 
0
 

Author Comment

by:Ruttensoft
ID: 33430765
Hm, I solved it with replacing the Stackpanel on the DataTemplate with a ContentPresenter, and then I am binding the Stackpanel to the Source of the ContentPresenter... That's all...
0
 
LVL 8

Assisted Solution

by:unmeshdave
unmeshdave earned 500 total points
ID: 33430809
ok that is static binding, I was under impression that you want to do it dynamically I mean at runtime. :) all the best. you can close this question as it is already solved.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question