Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataTemplate question...

Posted on 2010-08-12
3
Medium Priority
?
314 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 2000 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 2000 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 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