첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

728x90
반응형
728x170

TestProject.zip
0.01MB

▶ ProgressControl.xaml

<UserControl x:Class="TestProject.ProgressControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TestProject">
    <UserControl.Resources>
        <Style TargetType="{x:Type local:ProgressControl}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:ProgressControl}">
                        <Viewbox Stretch="Fill">
                            <Grid
                                Margin="10"
                                Width="180"
                                Height="100"
                                RenderTransformOrigin="0.5 0.5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Canvas Name="barCanvas1" Grid.Column="0"
                                    Margin="2 0"
                                    Width="30"
                                    Height="50"
                                    Background="CornflowerBlue" />
                                <Canvas Name="barCanvas2" Grid.Column="1"
                                    Margin="2 0"
                                    Width="30"
                                    Height="50"
                                    Background="CornflowerBlue" />
                                <Canvas Name="barCanvas3" Grid.Column="2"
                                    Margin="2 0"
                                    Width="30"
                                    Height="50"
                                    Background="CornflowerBlue" />
                                <Canvas Name="barCanvas4" Grid.Column="3"
                                    Margin="2 0"
                                    Width="30"
                                    Height="50"
                                    Background="CornflowerBlue" />
                                <Canvas Name="barCanvas5" Grid.Column="4"
                                    Margin="2 0"
                                    Width="30"
                                    Height="50"
                                    Background="CornflowerBlue" />
                            </Grid>
                        </Viewbox>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="SizeChanged">
                                <EventTrigger.Actions>
                                    <BeginStoryboard>
                                        <Storyboard
                                            FillBehavior="HoldEnd"
                                            RepeatBehavior="Forever">
                                            <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetName="barCanvas1"
                                                Storyboard.TargetProperty="Height"
                                                BeginTime="00:00:00"
                                                Duration="00:00:00.8">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00"    Value="50"  />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.15" Value="100" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.25" Value="100" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.4"  Value="50"  />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetName="barCanvas2"
                                                Storyboard.TargetProperty="Height"
                                                BeginTime="00:00:00.1"
                                                Duration="00:00:00.8">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00"    Value="50"  />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.15" Value="100" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.25" Value="100" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.4"  Value="50"  />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetName="barCanvas3"
                                                Storyboard.TargetProperty="Height"
                                                BeginTime="00:00:00.2"
                                                Duration="00:00:00.8">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00"    Value="50"  />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.15" Value="100" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.25" Value="100" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.4"  Value="50"  />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetName="barCanvas4"
                                                Storyboard.TargetProperty="Height"
                                                BeginTime="00:00:00.3"
                                                Duration="00:00:00.8">
                                                <LinearDoubleKeyFrame Value="50"  KeyTime="00:00:00"    />
                                                <LinearDoubleKeyFrame Value="100" KeyTime="00:00:00.15" />
                                                <LinearDoubleKeyFrame Value="100" KeyTime="00:00:00.25" />
                                                <LinearDoubleKeyFrame Value="50"  KeyTime="00:00:00.4"  />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetName="barCanvas5"
                                                Storyboard.TargetProperty="Height"
                                                BeginTime="00:00:00.4"
                                                Duration="00:00:00.8">
                                                <LinearDoubleKeyFrame Value="50"  KeyTime="00:00:00"    />
                                                <LinearDoubleKeyFrame Value="100" KeyTime="00:00:00.15" />
                                                <LinearDoubleKeyFrame Value="100" KeyTime="00:00:00.25" />
                                                <LinearDoubleKeyFrame Value="50"  KeyTime="00:00:00.4"  />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>    
    </UserControl.Resources>
</UserControl>

 

728x90

 

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TestProject"
    Width="800"
    Height="600"
    Title="진행 컨트롤 사용하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <local:ProgressControl
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Width="100"
            Height="100" />
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요