开发者

Render List<Canvas> as list items (or itemscontrol)

I've effectively got a List or a List, XAML that represents the canvas elements... as a return from some stuff I have no control of.

I've been moderately successful 开发者_如何转开发rendering via stackpanel.children.add etc, however want to start having the list of canvas within a virtualizing panel or list.

I've set itemssource and datacontext on the <ItemsControl> and set the <DataTemplate> as such

<DataTemplate>
   <ContentControl content="{Binding Path=CanvasBody}"/> 
</DataTemplate>

This effectively turns entire silverlight body white/blank. I dont really care how I ultimately get to the desired result which is a list of the rendered canvas's... preferably virtualized for speed.

Its a retarded problem, and not ideal as far as how silverlight apps are built, I know...

I'd really appreciate any pointers. THANKS!


Generally to display a list of elements you bind the items control itemssource property to the list and then set a datatemplate for it which displays the desired properties of the list item type. You dont need to set content control. Beyond that I cant see what exactly you are asking.

<DataTemplate>
    <Grid>
        <TextBlock Text="{Binding ExampleProperty1}"/>
    </Grid>
</DataTemplate>

codebehind file:

public class ExampleClass
{
    public String ExampleProperty1
    {
        get
        {
            return "TEST";
        }
    }
}

public List<ExampleClass> List {get;} // note that this must be a public PROPERTY,    
                                      // not a field!
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜