询问者
Wpf 3d 程序,如何保证在宽度增加的时候,视觉对象保持位置以及大小不变

问题
全部回复
-
Hi jinli.zh,
>>Viewport3D包含在Grid里。当Grid由原来的800宽度,变成1600宽度时,3d对象会相应的放大。这个时候将摄像机由原来的z 30 变成 z 60 ,这样3d 对象近似大小未变。然后位置却发生了变动。那么如何保持位置以及大小不变呢?
你是由于调整Grid的大小后,Viewport3D的相对位置发生了变化。
你可以尝试使用Canvas,并将Viewport3D放置在里面。或者在Grid变化的同时调整Viewport3D相对的位置。<Grid Height="450" Width="800"> <Canvas> <Viewport3D Name="viewport3D1" Width="600" Height="400" >
Best regards
Yong Lu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
Hi jinli.zh,
canvas 可以设置Top 和left的值来国定左右侧的对象。然后中间通过计算可以添加多了。
Canvas.SetLeft(greenRectangle, 110); Canvas.SetTop(greenRectangle, 110);
Best regards
Yong LuMSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.