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

728x90
반응형

■ ItemsControl 엘리먼트 : Template/ItemsPanel/ItemTemplate/ItemContainerStyle 속성 사용하기

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


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:local="clr-namespace:TestProject"

    Width="800"

    Height="600"

    Title="ItemsControl 엘리먼트 : Template/ItemsPanel/ItemTemplate/ItemContainerStyle 속성 사용하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Window.Resources>

        <local:TaskCollection x:Key="TaskCollectionKey" />

    </Window.Resources>

    <Grid>

        <ItemsControl

            HorizontalAlignment="Center"

            VerticalAlignment="Center"

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

            <ItemsControl.Template>

                <ControlTemplate TargetType="ItemsControl">

                    <Border

                        BorderBrush="Black"

                        BorderThickness="3"

                        CornerRadius="15">

                        <ItemsPresenter />

                    </Border>

                </ControlTemplate>

            </ItemsControl.Template>

            <ItemsControl.ItemsPanel>

                <ItemsPanelTemplate>

                    <WrapPanel />

                </ItemsPanelTemplate>

            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>

                <DataTemplate>

                    <DataTemplate.Resources>

                        <Style TargetType="TextBlock">

                            <Setter Property="HorizontalAlignment" Value="Center" />

                        </Style>

                    </DataTemplate.Resources>

                    <Grid>

                        <Ellipse

                            Stroke="Black"

                            StrokeThickness="3"

                            Fill="Gold" />

                        <StackPanel

                            HorizontalAlignment="Center"

                            VerticalAlignment="Center">

                            <TextBlock

                                Margin="5"

                                Text="{Binding Path=Priority}" />

                            <TextBlock

                                Margin="5"

                                Text="{Binding Path=TaskName}" />

                        </StackPanel>

                    </Grid>

                </DataTemplate>

            </ItemsControl.ItemTemplate>

            <ItemsControl.ItemContainerStyle>

                <Style>

                    <Setter Property="Control.Margin" Value="10" />

                    <Setter Property="Control.Width" Value="100" />

                    <Setter Property="Control.Height" Value="100" />

                    <Style.Triggers>

                        <Trigger

                            Property="Control.IsMouseOver" Value="True">

                                <Setter Property="Control.ToolTip"

                                    Value="{Binding RelativeSource={x:Static RelativeSource.Self},

                                        Path=Content.Description}" />

                        </Trigger>

                    </Style.Triggers>

                </Style>

            </ItemsControl.ItemContainerStyle>

        </ItemsControl>

    </Grid>

</Window>

 

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

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

댓글을 달아 주세요