Skip to main content

Microsoft Silverlight

Answered Question How can I bind listbox.itemtemplate by behind code?RSS Feed

(0)

jv9
jv9

Member

Member

96 points

97 Posts

How can I bind listbox.itemtemplate by behind code?

I try to bind listbox.itemtemplate without xmal code. How can I do that? Thanks.

jay nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Answered Question

Re: How can I bind listbox.itemtemplate by behind code?

This is the thing that you want to develop?

            DataTemplate d1 = new DataTemplate();
            string xamlCode = "<DataTemplate x:Name='dt' xmlns='http://schemas.microsoft.com/client/2007' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:basics='clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls'  >"
                + "'150' Height='32' Margin='5' Text='it works...'  HorizontalAlignment='Left' />"
                + "";

            d1 = (DataTemplate)XamlReader.Load(xamlCode);
            myList.ItemTemplate = d1;
            //for test purpose
            myList.ItemsSource = "j a y".Split();
 

 

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities