첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ VisualBrush 엘리먼트를 사용하는 방법을 보여준다.

▶ 예제 코드 (XAML)

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Page.Resources>
        <Style TargetType="{x:Type Rectangle}">
            <Setter Property="Margin"          Value="5"     />
            <Setter Property="Width"           Value="150"   />
            <Setter Property="Height"          Value="150"   />
            <Setter Property="Stroke"          Value="Black" />
            <Setter Property="StrokeThickness" Value="1"     />
        </Style>
    </Page.Resources>
    <StackPanel
        Margin="10 10 10 10"
        Orientation="Horizontal"
        VerticalAlignment="Top">
        <Rectangle>
            <Rectangle.Fill>
                <VisualBrush TileMode="Tile">
                    <VisualBrush.Visual>
                        <StackPanel>
                            <StackPanel.Background>
                                <DrawingBrush>
                                    <DrawingBrush.Drawing>
                                        <GeometryDrawing>
                                            <GeometryDrawing.Brush>
                                                <RadialGradientBrush>
                                                    <GradientStop Offset="0.0" Color="MediumBlue" />
                                                    <GradientStop Offset="1.0" Color="White"      />
                                                </RadialGradientBrush>
                                            </GeometryDrawing.Brush>
                                            <GeometryDrawing.Geometry>
                                                <GeometryGroup>
                                                    <RectangleGeometry Rect="0 0 0.5 0.5"     />
                                                    <RectangleGeometry Rect="0.5 0.5 0.5 0.5" />
                                                </GeometryGroup>
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </StackPanel.Background>
                            <TextBlock
                                Margin="10"
                                FontSize="10pt">
                                Hello, World!
                            </TextBlock>
                        </StackPanel>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle>
            <Rectangle.Fill>
                <VisualBrush
                    Stretch="Uniform"
                    TileMode="Tile"
                    Viewport="0 0 1 0.25">
                    <VisualBrush.Visual>
                        <StackPanel Background="White">
                            <TextBlock
                                Margin="1"
                                FontSize="10pt">
                                Hello, World!
                            </TextBlock>
                        </StackPanel>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle>
            <Rectangle.Fill>
                <VisualBrush
                    Stretch="Uniform"
                    Viewport="0 0 1 0.25"
                    TileMode="Tile">
                    <VisualBrush.Visual>
                        <StackPanel Background="White">
                            <TextBlock
                                FontSize="10pt"
                                Margin="1">
                                Hello, World!
                            </TextBlock>
                        </StackPanel>
                    </VisualBrush.Visual>
                    <VisualBrush.RelativeTransform>
                        <RotateTransform
                            CenterX="0.5"
                            CenterY="0.5"
                            Angle="-45" />
                    </VisualBrush.RelativeTransform>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle>
            <Rectangle.Fill>
                <VisualBrush>
                    <VisualBrush.Visual>
                        <StackPanel Background="White">
                            <Button Margin="1">Button Control</Button>
                            <Button Margin="1">Another Button</Button>
                        </StackPanel>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
    </StackPanel>
</Page>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요