silverlight - How do I use a Silverlight2 ItemsControl to position a collection of items on a canvas? -


In WPF, you can create a list box in the form of an item panel and position item on the status canvas with a canvas . To do this, the code looks like this:

  & lt; List Box Itemsource = "{Binding}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text block text = "{binding path = name}" /> & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; ListBox.ItemsPanel & gt; & Lt; ItemsPanelTemplate & gt; & Lt; Canvas width = "200" height = "200" /> & Lt; / ItemsPanelTemplate & gt; & Lt; /ListBox.ItemsPanel> & Lt; ListBox.ItemContainerStyle & gt; & Lt; Style TargetType = "ListBoxItem" & gt; & Lt; Setter Property = "canvas.lift" value = "{binding path = XPOS}" /> & Lt; Setter property = "canvas.Tap" value = "{binding path = YPos}" /> & Lt; / Style & gt; & Lt; /ListBox.ItemContainerStyle> & Lt; / ListBox & gt;  

Can you do the same in the Silverlight 2 List box, or preferably in an item control?

I have found the a solution, but (for me) it smells is.

  & lt; List Box Itemsource = "{Binding}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Canvas width = "200" height = "200" & gt; & Lt; TextBlock Text = "{binding path = name}" canvas. Lift = "{binding path = XPos}" canvas. Tap = "{binding path = YPos}" /> & Lt; / Canvas & gt; & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; ListBox.ItemsPanel & gt; & Lt; ItemsPanelTemplate & gt; & Lt; Canvas width = "200" height = "200" /> & Lt; / ItemsPanelTemplate & gt; & Lt; /ListBox.ItemsPanel> & Lt; / ListBox & gt;  

Each item has its canvas, so they stacked on top of each.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -