Solved

DataTemplate question...

Posted on 2010-08-12
3
301 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now