[MainPage.xaml]


<UserControl x:Class="RiaComboBox.MainPage"

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

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

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

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

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel>

            <TextBlock Text="인코딩"></TextBlock>

            <ComboBox x:Name="enc" SelectedIndex="0">

                <ComboBox.Items>

                    <ComboBoxItem Content="Text" />

                    <ComboBoxItem Content="HTML" />

                    <ComboBoxItem Content="Mixed" />

                </ComboBox.Items>

            </ComboBox>

            <Button x:Name="btnSelect" Content="선택" />

            <TextBlock x:Name="lbl" />

        </StackPanel>       

    </Grid>

</UserControl>

 





[MainPage.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaComboBox

{

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

            btnSelect.Click += new RoutedEventHandler(btnSelect_Click);

        }

 

        void btnSelect_Click(object sender, RoutedEventArgs e)

        {

            //lbl.Text = enc.SelectedItem.ToString(); // 선택된 항목을 출력

            ComboBox cb = this.enc as ComboBox;

            ListBoxItem lbi = cb.SelectedItem as ListBoxItem; // 선택된 항목 한개를 가져오기

            lbl.Text = lbi.Content.ToString(); // Content의 값을 문자열로 : Text, HTML, Mixed

        }

    }

}

 































'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글

ProgressBar 컨트롤  (0) 2009.12.02
ListBox 컨트롤  (0) 2009.12.02
ScrollBar 컨트롤  (0) 2009.12.02
ScrollViewer 컨트롤  (0) 2009.12.02
ToolTip 컨트롤 (풍선도움말 제공)  (0) 2009.12.02
Posted by holland14
: