첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

■ ObjectDataProvider 엘리먼트 : Colors 클래스의 색상 정적 속성 구하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


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:sys="clr-namespace:System;assembly=mscorlib"

    xmlns:local="clr-namespace:TestProject"

    Width="800"

    Height="600"

    Title="ObjectDataProvider 엘리먼트 : Colors 클래스의 색상 정적 속성 구하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Window.Resources>

        <ObjectDataProvider x:Key="ColorsTypeObjectDataProviderKey"

            ObjectType="{x:Type sys:Type}"

            MethodName="GetType">

            <ObjectDataProvider.MethodParameters>

                <sys:String>

                    System.Windows.Media.Colors, PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

                </sys:String>

            </ObjectDataProvider.MethodParameters>

        </ObjectDataProvider>

        <ObjectDataProvider x:Key="ColorsPropertyObjectDataProviderKey"

            ObjectInstance="{StaticResource ColorsTypeObjectDataProviderKey}"

            MethodName="GetProperties" />

    </Window.Resources>

    <Grid>

        <Grid Margin="10">

            <Grid.ColumnDefinitions>

                <ColumnDefinition Width="*"   />

                <ColumnDefinition Width="10" />

                <ColumnDefinition Width="200" />

            </Grid.ColumnDefinitions>

            <Border Grid.Column="0"

                BorderThickness="1"

                BorderBrush="Black">

                <Rectangle Name="rectangle">

                    <Rectangle.Fill>

                        <local:CustomBrush x:Name="customBrush" />

                    </Rectangle.Fill>

                </Rectangle>

            </Border>

            <Grid Grid.Column="2">

                <Grid.RowDefinitions>

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="*"    />

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="Auto" />

                </Grid.RowDefinitions>

                <Label Grid.Row="0" Content="그라디언트" />

                <ListBox Name="colorListBox" Grid.Row="1"

                    Margin="0 10 0 0">

                    <ListBox.ItemTemplate>

                        <DataTemplate>

                            <Rectangle

                                HorizontalAlignment="Center"

                                Width="170"

                                Height="20"

                                Fill="{Binding Path=Name}" />

                        </DataTemplate>

                    </ListBox.ItemTemplate>

                </ListBox>

                <StackPanel Grid.Row="2"

                    Margin="0 10 0 0"

                    Orientation="Horizontal">

                    <ComboBox Name="colorComboBox"

                        Width="90"

                        Height="25"

                        ItemsSource="{Binding Source={StaticResource ColorsPropertyObjectDataProviderKey}}">

                        <ComboBox.ItemTemplate>

                            <DataTemplate>

                                <Rectangle

                                    Width="70"

                                    Height="20"

                                    Fill="{Binding Path=Name}" />

                            </DataTemplate>

                        </ComboBox.ItemTemplate>

                    </ComboBox>

                    <Button Name="addButton"

                        Margin="10 0 0 0"

                        Width="50"

                        Content="추가" />

                    <Button Name="deleteButton"

                        Margin="10 0 0 0"

                        Width="40"

                        Content="삭제" />

                </StackPanel>

                <Label Grid.Row="3"

                    Margin="0 10 0 0"

                    Content="그라디언트 크기" />

                <Slider Grid.Row="4"

                    Margin="0 10 0 0"

                    Minimum="10"

                    Maximum="600"

                    Value="{Binding GradientSize, ElementName=customBrush}" />

                <Label Grid.Row="5"

                    Margin="0 10 0 0"

                    Content="그라디언트 디테일" />

                <Slider Grid.Row="6"

                    Margin="0 10 0 0"

                    Minimum="0.1"

                    Maximum="100"

                    Value="{Binding GradientDetail, ElementName=customBrush}" />

            </Grid>

        </Grid>

    </Grid>

</Window>

 

------------------------------------------------------------------------------------------------------------------------

728x90
반응형
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요