"Programming WPF" translation 7th Chapter 1. Graphics Basics

Source: Internet
Author: User

WPF makes it easy to use graphics in your applications and the ability to develop your graphics card more easily. There are many aspects of the graphical framework to achieve this goal. One of the most important is the synthesis.

7.1.1 synthesis

Graphical elements can be grouped into any part of your user interface. Many GUI technologies are easy to isolate graphics into an independent world. This requires a "joystick"--when moving a world of buttons, text boxes and other frames into shape and image in another world, because in many systems, the two worlds have different programming models.

For example, cocoa of Windows forms and Mac OS provide the ability to arrange controls in a form, and to create a program that interacts with those controls. They also provide APIs that provide advanced, fully scalable 2-D space drawing tools. (For GDI + in Windows Forms, Quartz 2D in OS X.) However, these drawing APIs are different from the control APIs. The drawing base is very different from the controls in these systems, and you can't mix these two freely.

WPF, on the other hand, takes shape as an element in the UI tree, just like any other element. Therefore, we are free to mix them in any type of element. Example 7-1 shows a variety of examples.

Example 7-1

<DockPanel>
    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
        <TextBlock>Mix</TextBlock>
        <Rectangle Fill="Red" Width="20" />
        <TextBlock>text</TextBlock>
        <Ellipse Fill="Blue" Width="40" />
        <TextBlock>and</TextBlock>
        <Button>Controls</Button>
    </StackPanel>
    <Ellipse DockPanel.Dock="Left" Fill="Green" Width="100" />
    <Button DockPanel.Dock="Left">Foo</Button>
    <TextBlock FontSize="24" TextWrap="Wrap">
        And of course you can put graphics into
        your text: <Ellipse Fill="Cyan" Width="50" Height="20" />
    </TextBlock>
</DockPanel>

As you can see, the graphical elements are added to the tag without gaps. Look and work together-just as it does with any other element, the result is shown in Figure 7-1.

Figure 7-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.