Live Chat Icon For mobile
Live Chat Icon

WPF FAQ - Border

Find answers for the most frequently asked questions
Expand All Collapse All

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.
  • Permalink

    WPF lets you specify a negative value for the Border’s Margin. This way the available size for the children of the Border will not reduce when a Border is rendered.

    
    <Border Margin='-1,-1,-1,-1' BorderThickness='1' BorderBrush='Black'>
          <MyControls/> 
     </Border>
    
    Permalink

    The following example animates the thickness of a border by using the ‘ThicknessAnimation’ property.

    The example uses the ’BorderThickness’ property of Border.

    [XAML]
    
    <!-- an animation on the BorderThickness property of a Border. -->
    <Page  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
      xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' >
    
      <StackPanel Orientation='Vertical' HorizontalAlignment='Center'>
        <Border Background='#99FFFFFF' BorderBrush='#CCCCFF' BorderThickness='1'
        Margin='0,60,0,20' Padding='20'  >
          <Border.Triggers>
            <EventTrigger RoutedEvent='Border.Loaded'>
              <BeginStoryboard>
                <Storyboard>
    
                  <!-- BorderThickness animates from left=1, right=1, top=1, and bottom=1 to
                  left=28, right=28, top=14, and bottom=14 over one second. -->
                  <ThicknessAnimation
                    Storyboard.TargetProperty='BorderThickness'
                    Duration='0:0:1.5' FillBehavior='HoldEnd' From='1,1,1,1' To='28,14,28,14' />
                </Storyboard>
              </BeginStoryboard>
            </EventTrigger>
          </Border.Triggers>
          <TextBlock>
            This example shows how to use the ThicknessAnimation to create
            an animation on the BorderThickness property of a Border.
          </TextBlock>
        </Border>
      </StackPanel>
    </Page>
    
    
    Permalink

    Each model has a particular location in the scene. In order to move the model around the scene, rotate the model or to change it’s size, it is not practical to change the vertices of a model like the 2D objects. Instead 3D models have the ‘Transform’ property with which you can move the models, change their sizes or rotate them.

    Permalink

    The following example shows how to define a BulletDecorator control that uses an ’image’ as the Bullet and a ’non-text element’ as the Child.
    In this example, the Bullet object centers itself next to the non-text element.

    [XAML]
    
    <BulletDecorator Grid.Row='3' Grid.Column='0' Margin='0,5,0,0'>
      <BulletDecorator.Bullet>
        <Image Source='images\apple.jpg'/>
      </BulletDecorator.Bullet>
      <Ellipse Height='75' Width='50' Fill='Purple' 
               HorizontalAlignment='Left' ></Ellipse>
    </BulletDecorator>
    
    Permalink

    Share with

    Couldn't find the FAQs you're looking for?

    Please submit your question and answer.