0

Updating FOV from bound code

Anonymous 5 years ago 0
This discussion was imported from CodePlex

cobra18t wrote at 2011-12-20 17:02:

I have the field of view of a perspective camera bound to a int variable in the code behind. Right now, it will not update the field of view until I "flick" the mouse with the right mouse button. Just rotating around will not cause the update. Is there something, perhaps a function that I can call, to force the camera FOV to update automatically?


objo wrote at 2011-12-21 21:36:

Sorry, I don't understand the problem here.

Here is an example binding the FieldOfView property of a PerspectiveCamera to a Slider

<Grid>
	<helix:HelixViewport3D>
        	<helix:DefaultLights/>
                <helix:CubeVisual3D SideLength="4" Fill="Blue"/>
                <helix:HelixViewport3D.Camera>
                	<PerspectiveCamera FieldOfView="{Binding Value, ElementName=FieldOfViewSlider}"/>
                </helix:HelixViewport3D.Camera>
        </helix:HelixViewport3D>
        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8">
                <Slider Name="FieldOfViewSlider" Value="45" Minimum="10" Maximum="160" Width="200"/>
        </StackPanel>
</Grid>
Binding to a property in the DataContext should work the same way. Are you raising INotifyPropertyChanged events?


cobra18t wrote at 2011-12-21 21:45:

Let me see if I can clarify...I am an idiot and forgot to raise a propertychanged event. It works just fine now.