RadioButtons.ItemsSource 속성

정의

컨트롤의 콘텐츠를 생성하는 데 사용되는 개체 원본을 가져오거나 설정합니다.

public:
 property Platform::Object ^ ItemsSource { Platform::Object ^ get(); void set(Platform::Object ^ value); };
IInspectable ItemsSource();

void ItemsSource(IInspectable value);
public object ItemsSource { get; set; }
var object = radioButtons.itemsSource;
radioButtons.itemsSource = object;
Public Property ItemsSource As Object

속성 값

Object

Platform::Object

IInspectable

컨트롤의 콘텐츠를 생성하는 데 사용되는 개체입니다. 기본값은 null입니다.

예제

다음 예제에서는 컨트롤을 사용자 지정 데이터 원본에 바인딩하는 방법을 보여 줍니다.

<!-- xmlns:muxc="using:Microsoft.UI.Xaml.Controls -->
 <muxc:RadioButtons Header="Background color"
                    SelectionChanged="BackgroundColor_SelectionChanged"
                    ItemsSource="{x:Bind colorOptionItems}"/>

...

<Border x:Name="ExampleBorder" Width="100" Height="100"/>
public sealed partial class MainPage : Page
{
    // Custom data item.
    public class ColorOptionDataModel
    {
        public string Label { get; set; }
        public SolidColorBrush ColorBrush { get; set; }

        public override string ToString()
        {
            return Label;
        }
    }

    List<ColorOptionDataModel> colorOptionItems;

    public MainPage1()
    {
        this.InitializeComponent();

        colorOptionItems = new List<ColorOptionDataModel>();
        colorOptionItems.Add(new ColorOptionDataModel()
            { Label = "Red", ColorBrush = new SolidColorBrush(Colors.Red) });
        colorOptionItems.Add(new ColorOptionDataModel()
            { Label = "Green", ColorBrush = new SolidColorBrush(Colors.Green) });
        colorOptionItems.Add(new ColorOptionDataModel()
            { Label = "Blue", ColorBrush = new SolidColorBrush(Colors.Blue) });
    }

    private void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var option = e.AddedItems[0] as ColorOptionDataModel;
        ExampleBorder.Background = option?.ColorBrush;
    }
}

설명

자세한 정보, 디자인 지침 및 코드 예제는 라디오 단추를 참조하세요.

ItemsSource 속성의 동작에 대한 자세한 내용은 ItemsControl.ItemsSource를 참조하세요.

적용 대상

추가 정보