블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
반응형

Category

Recent Post

Recent Comment

Archive

2009. 12. 2. 15:02 .Net Project/SilverLight 3.0
반응형
  ListBox 컨트롤
- ListBoxItem으로 설정된 컬렉션 컨트롤 입니다
- ItemsControl과 유하나 항목을 선택할 수 있다는 특징이  존재...


 
 ListBox.Xaml

<UserControl x:Class="RiaListBox.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">

    <StackPanel>

        <ListBox x:Name="lstFavorites" Width="150" Height="150">

            <ListBox.Items>

                <ListBoxItem>

                    <TextBlock Text="C#" 
                               FontSize
="20"></TextBlock>               

                </ListBoxItem>

                <ListBoxItem>

                    <TextBlock Text="ASP.NET" FontSize="20"></TextBlock>

                </ListBoxItem>

                <ListBoxItem>

                    <TextBlock Text="J-Query" FontSize="20"></TextBlock>

                </ListBoxItem>

                <ListBoxItem>

                    <TextBlock Text="SilverLight" FontSize="20"></TextBlock>

                </ListBoxItem>

            </ListBox.Items>          

        </ListBox>

        <TextBlock x:Name="lblDisplay" FontSize="20" Width="100"
                                       Height
="20"></TextBlock>

    </StackPanel>

</UserControl> 

  ListBox.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 RiaListBox

{

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

            lstFavorites.SelectionChanged +=
              
new SelectionChangedEventHandler(lstFavorites_SelectionChanged);

        }

 

        void lstFavorites_SelectionChanged
                                   (
object sender, SelectionChangedEventArgs e)

        {

            this.lblDisplay.Text =
                ((
TextBlock)((ListBoxItem)this.lstFavorites.Items[

                lstFavorites.SelectedIndex]).Content).Text;           

        }

    }

} 





반응형

'.Net Project > SilverLight 3.0' 카테고리의 다른 글

51장 Slider 컨트롤  (0) 2009.12.02
50장 ProgressBar 컨트롤  (0) 2009.12.02
48장 ComboBox 컨트롤  (0) 2009.12.02
47장 RoutedEventArgs 컨트롤  (0) 2009.12.01
46장 InkPresenter 컨트롤  (0) 2009.12.01
posted by Magic_kit