powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Extended WPF Toolkit. PropertyGrid, привязка ComboBox а ля LookupList
3 сообщений из 3, страница 1 из 1
Extended WPF Toolkit. PropertyGrid, привязка ComboBox а ля LookupList
    #38702243
Кифирчик
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Каким образом возможно прицепить к PropertyGrid выпадающий список привязанный к определенному "ключу" объекта
в примере, надо чтоб комбобокс отображал то что в Country_GUID поля City, и при выборе данных в комбобоксе они попадали в Country_GUID.
если в ксампле жестко задать
SelectedValue="ef6c3f62-3fa8-45fe-84ab-f0d898e072c3"
то, по крайней мере визуально, комбобокс по умолчанию выбирает то что надо, а если биндинг к Country_GUID
SelectedValue="{Binding Country_GUID}" - не работает

Код: xml
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.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
<Window x:Class="ComboBox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow" Height="350" Width="525">
    <Grid>      
        <xctk:PropertyGrid x:Name="_propertyGrid"
                           Margin="2" 
                           AutoGenerateProperties="False" 
                           SelectedObject="{Binding Path=City}">

            <xctk:PropertyGrid.PropertyDefinitions>
                <xctk:PropertyDefinition Name="City_Name" />
                <xctk:PropertyDefinition Name="CountryList" />
            </xctk:PropertyGrid.PropertyDefinitions>

            <xctk:PropertyGrid.EditorDefinitions>

                <xctk:EditorDefinition>
                    <xctk:EditorDefinition.PropertiesDefinitions>
                        <xctk:PropertyDefinition Name="CountryList"/>
                    </xctk:EditorDefinition.PropertiesDefinitions>
                    <xctk:EditorDefinition.EditorTemplate>
                        <DataTemplate>
                            <!--<ComboBox ItemsSource="{Binding Value}" 
                                      DisplayMemberPath="Country_Name" 
                                      SelectedValuePath="Country_GUID"
                                      SelectedIndex="0"
                                      />-->
                            <ComboBox ItemsSource="{Binding Value}" 
                                      DisplayMemberPath="Country_Name" 
                                      SelectedValuePath="Country_GUID"
                                      SelectedValue="ef6c3f62-3fa8-45fe-84ab-f0d898e072c3"
                                      />
                            <!--<ComboBox ItemsSource="{Binding Value}" 
                                      DisplayMemberPath="Country_Name" 
                                      SelectedValuePath="Country_GUID"
                                      SelectedValue="{Binding Country_GUID}"
                                      />-->
                        </DataTemplate>
                    </xctk:EditorDefinition.EditorTemplate>
                </xctk:EditorDefinition>

            </xctk:PropertyGrid.EditorDefinitions>
            
        </xctk:PropertyGrid>

    </Grid>
</Window>



Код: c#
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.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Model m = new Model()
            {
                City = new City()
                {
                    City_Name = "Kuala Lumpur"
                    ,
                    Country_GUID = Guid.Parse("ef6c3f62-3fa8-45fe-84ab-f0d898e072c3")
                }
            };
            this.DataContext = m;
        }

        
    }

    public class Model
    {
        public City City { get; set; }
    }

    public class City
    {
        public string City_Name { get; set; }
        public Guid Country_GUID { get; set; }

        public List<Country> CountryList
        {
            get
            {
                List<Country>  countryList = new List<Country>();
                countryList.Clear();
                countryList.Add(new Country() { Country_GUID = Guid.Parse("ef6c3f62-3fa8-45fe-84ab-f0d898e072c3"), Country_Name = "Malaysia" });
                countryList.Add(new Country() { Country_GUID = Guid.Parse("0fa5d94d-cf61-4807-8377-45209f268d17"), Country_Name = "Singapore" });
                countryList.Add(new Country() { Country_GUID = Guid.Parse("5bd5eea6-26de-40d0-b0bc-5b897c0318df"), Country_Name = "USA" });
                return countryList;
            }
            set{}
        }
    }

    public class Country
    {
        public Guid Country_GUID { get; set; }
        public string Country_Name { get; set; }

        public override string ToString()
        {
            return Country_Name;
        }
    }
...
Рейтинг: 0 / 0
Extended WPF Toolkit. PropertyGrid, привязка ComboBox а ля LookupList
    #38702249
Кифирчик
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
в приложении солюшн с кодом
...
Рейтинг: 0 / 0
Extended WPF Toolkit. PropertyGrid, привязка ComboBox а ля LookupList
    #38702252
Кифирчик
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
библиотеки Extended.Wpf.Toolkit не поместились в 150 кб разрешенного размера приложений
подтянуть из nuget (package mamager console) можно так
Код: plaintext
PM> Install-Package Extended.Wpf.Toolkit
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Extended WPF Toolkit. PropertyGrid, привязка ComboBox а ля LookupList
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]