Full width home advertisement

Post Page Advertisement [Top]

Short posts are nice, yeah!

The result you want to see:


TestCombobox.xaml
<Window x:Class="TelerikWpfApp1.TestComboBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:telerikWpfApp1="clr-namespace:TelerikWpfApp1"
        Title="TestComboBox" Height="300" Width="300">
    <Window.Resources>
        <telerik:EnumDataSource EnumType="telerikWpfApp1:PlayerType"
                                x:Key="enumDataSource" />
    </Window.Resources>
    <Grid>
        <telerik:RadComboBox SelectedValue="{Binding Path=PlayerType}"
                             ItemsSource="{Binding Source={StaticResource enumDataSource}}"
                             DisplayMemberPath="DisplayName"
                             SelectedValuePath="Value" />
    </Grid>
</Window>

TestCombobox.xaml.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
namespace TelerikWpfApp1
{
    public partial class TestComboBox
    {
        public TestComboBox()
        {
            InitializeComponent();
            this.DataContext = new Player()
            {
                PlayerType = PlayerType.Defender,
            };
        }
    }
    public enum PlayerType
    {
        [Description("The forward")]
        Forward,
        [Description("The defender")]
        Defender,
        [Description("The goal keeper")]
        GoalKeeper,
    }
    public class Player
    {
        public PlayerType PlayerType { get; set; }
    }
}

Комментариев нет:

Отправить комментарий

Bottom Ad [Post Page]

| Дизайн Colorlib