How lights are useful in 3D graphics ?
Lights are similar to lights in real life. Light objects are used to illuminate a part of a scene. Lights can be used to create shadow effects. In a 3D scene at least one light has to be added to make the scene visible. WPF has four different types of lights with unique functionalities. The following are the types of light available in WPF. AmbientLight – provides uniform lighting to all the objects in a 3D scene. DirectionalLight – It is like a distant light source. It does not have a location but has a direction. PointLight – It illuminates like a nearby light source. It has a location and provides light effect from the location and objects in the scene are illuminated based on the location and position of the point light. SpotLight – It is similar to a pointlight. It provides illumination in a cone shape. The ‘InnerConeAngle’ and ‘OuterConeAngle’ properties determine the illumination of the objects in the 3D scene.
How can I get an enumerator to the ContentControl’s logical child elements ?
The LogicalChildren of a ContentControl is of ‘protected-type’ access. You can derive a custom class from it and then expose a public version of the ‘LogicalChildren’ property. [C#] public class SPanel : StackPanel { public System.Collections.IEnumerator LogicalChildren { get { return base.LogicalChildren; } } }
How can I define a style for a ContentControl to give it a meaningful appearance in the UI ?
This can be done as follows. [XAML] <Style x:Key=’ContentCtrl’ TargetType=’ContentControl’> <Setter Property=’Background’ Value=’Red’/> <Setter Property=’Foreground’ Value=’Green’/> <Setter Property=’FontSize’ Value=’20’/> <Setter Property=’FontWeight’ Value=’Bold’/> <Setter Property=’Template’> <Setter.Value> <ControlTemplate TargetType=’ContentControl’> <Grid> <Ellipse Width='{TemplateBinding Width}’ Height='{TemplateBinding Width}’ Fill='{TemplateBinding Background}’/> <ContentPresenter VerticalAlignment=’Center’ HorizontalAlignment=’Center’/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> … <ContentControl Width=’75’ Height=’100′ Style='{StaticResource ContentCtrl}’ Content=’Hello’/>
How can I add a CommandBinding to a window using markup?
CommandBinding can be added to a window using markup. Note that in XAML, the CommandBindingCollection is not declared in the markup as an element and the collection object is inferred by the type that the property takes and you populate the property element with one or more CommandBinding elements. [XAML] <Window.CommandBindings> <CommandBinding Command=’ApplicationCommands.Open’ Executed=’OpenCmdExecuted’ CanExecute=’OpenCmdCanExecute’/> </Window.CommandBindings>
How do I access extended properties from a XAML tempalte?
Here is how you would access a Canvas.Left extended property for example: <DataTemplate x:Key=’MyTemplate1′> <Path Data='{Binding Geometry}’> <Path.RenderTransform> <!– The Item property returns a visual hosted inside the Canvas –> <RotateTransform Angle=’60’ CenterX='{Binding Item.(Canvas.Left)}’ CenterY='{Binding Item.(Canvas.Top)}’ > </RotateTransform> </Path.RenderTransform> </Path> </DataTemplate>