■ DataTemplate 엘리먼트 : 데이터 템플리트 설정 엘리먼트의 속성 바인딩 하기

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

<ListBox

    x:Class="TestProject.MultiListBox"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    mc:Ignorable="d"

    d:DesignWidth="200"

    d:DesignHeight="200"

    ScrollViewer.HorizontalScrollBarVisibility="Hidden"

    SelectionMode="Extended">

    <ListBox.ItemTemplate>

        <DataTemplate>

            <StackPanel

                Margin="1"

                Orientation="Horizontal">

                <CheckBox Name="itemCheckBox"

                    VerticalAlignment="Center"

                    Width="20"

                    IsChecked="{Binding IsChecked}" />

                <Image Name="itemImage"

                    VerticalAlignment="Center"

                    Margin="0 0 5 0"

                    Width="16"

                    Height="16"

                    Stretch="None"

                    Source="{Binding Icon}" />

                <TextBlock Name="itemTextBlock"

                    VerticalAlignment="Center"

                    Margin="0"

                    Width="{Binding RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}, Path=ActualWidth}"

                    Text="{Binding Text}" />

            </StackPanel>

        </DataTemplate>

    </ListBox.ItemTemplate>

</ListBox>

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

Posted by 사용자 icodebroker

댓글을 달아 주세요