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

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="XmlDataProvider 엘리먼트 : x:XData 엘리먼트를 사용해 XML 데이터 내장하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <XmlDataProvider x:Key="EmployeeXmlDataProviderKey" 
            XPath="Employees">
            <x:XData>
                <Employees xmlns="">
                    <Employee Name="Betty">
                        <BirthDate>1970/08/31</BirthDate>
                        <Face>IMAGE/Betty.png</Face>
                        <LeftHanded>False</LeftHanded>
                    </Employee>
                    <Employee Name="Edgar">
                        <BirthDate>1965/02/02</BirthDate>
                        <Face>IMAGE/Edgar.png</Face>
                        <LeftHanded>True</LeftHanded>
                    </Employee>
                    <Employee Name="Sally">
                        <BirthDate>1980/07/12</BirthDate>
                        <Face>IMAGE/Sally.png</Face>
                        <LeftHanded>True</LeftHanded>
                    </Employee>
                    <Employee Name="Jim">
                        <BirthDate>1975/06/15</BirthDate>
                        <Face>IMAGE/Jim.png</Face>
                        <LeftHanded>False</LeftHanded>
                    </Employee>
                    <Employee Name="Anne">
                        <BirthDate>1975/04/07</BirthDate>
                        <Face>IMAGE/Anne.png</Face>
                        <LeftHanded>True</LeftHanded>
                    </Employee>
                    <Employee Name="John">
                        <BirthDate>1955/12/02</BirthDate>
                        <Face>IMAGE/John.png</Face>
                        <LeftHanded>False</LeftHanded>
                    </Employee>
                </Employees>            
            </x:XData>
        </XmlDataProvider>
    </Window.Resources>
    <Grid>
        <ListBox Name="listBox"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            ItemsSource="{Binding Source={StaticResource EmployeeXmlDataProviderKey}, XPath=Employee}"
            SelectedValuePath="Face">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <local:RadialPanel Orientation="ByHeight" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <DockPanel Margin="3">
                        <Image DockPanel.Dock="Right"
                            Stretch="None"
                            Source="{Binding XPath=Face}" />
                        <UniformGrid Rows="3"
                            VerticalAlignment="Center" 
                            Margin="10">
                            <TextBlock
                                TextAlignment="Center" 
                                Text="{Binding XPath=@Name}" />
                            <TextBlock
                                TextAlignment="Center"
                                FontSize="12pt"
                                Text="{Binding XPath=BirthDate}" />
                            <TextBlock Name="leftHandedTextBlock"
                                TextAlignment="Center"
                                Text="Right-Handed" />
                        </UniformGrid>
                    </DockPanel>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding XPath=LeftHanded}" Value="True">
                            <Setter
                                TargetName="leftHandedTextBlock"
                                Property="Text"
                                Value="Left-Handed" />
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Image
            HorizontalAlignment="Center"
            VerticalAlignment="Center" 
            Stretch="None"
            Source="{Binding ElementName=listBox, Path=SelectedValue}" />
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요