开发者

Is there something like ItemsControl for use inside a Viewport3D?

I have a Viewport3D with a few items in it, and I want to add additional items to it that are from a collection that can be data bound to. Is there something like that, that would allow code like this:

<Viewport3D>
     <Viewport3D.Camera...>
  开发者_StackOverflow中文版   <ModelVisual3D>
         <ModelVisual3D.Content>
             <AmbientLight Color="White"/>
         </ModelVisual3D.Content>
     </ModelVisual3D>

     <ItemsControl ItemsSource="{Binding MyCollection}">
         <ItemsControl.ItemTemplate>
              <DataTemplate ...>
                   <ModelVisual3D ....>
              </DataTemplate>
         </ItemsControl.ItemTemplate>
     </ItemsControl>
</Viewport3D>


Josh smith used viewport3d to host a list of images.... http://joshsmithonwpf.wordpress.com/2008/03/30/animating-images-in-a-3d-itemscontrol/

Is this what you seek?


My solution to this was to use a standard itemscontrol, and stack Viewport3D controls on top of each other. This doesn't respect depth-ordering, but in my case I wanted the items in the itemscontrol to be in front of the rest of the elements anyways:

    <ItemsControl ItemsSource="{Binding XXX}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Grid/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="{x:Type XXX}">
                <Viewport3D Camera="{Binding Camera, ElementName=MainViewport}">
                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <AmbientLight Color="White"/>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>

                    <ModelVisual3D>
                      ...my template here...
                    </ModelVisual3D>
                </Viewport3D>

            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜