質問

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...>
     <ModelVisual3D>
         <ModelVisual3D.Content>
             <AmbientLight Color="White"/>
         </ModelVisual3D.Content>
     </ModelVisual3D>

     <ItemsControl ItemsSource="{Binding MyCollection}">
         <ItemsControl.ItemTemplate>
              <DataTemplate ...>
                   <ModelVisual3D ....>
              </DataTemplate>
         </ItemsControl.ItemTemplate>
     </ItemsControl>
</Viewport3D>
役に立ちましたか?

解決 2

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>

他のヒント

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?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top