كيفية ربط في WPF كائن كله إلى عنصر تحكم المستخدم؟
-
20-08-2019 - |
سؤال
ويستخدم الناس في كثير من الأحيان شيء من هذا القبيل:
<ListBox ItemsSource="{Binding ElementName=thisControl, Path=ListIndexes}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Label Content="{Binding Path=IndexName}"/>
<Label Content="{Binding Path=IndexValue}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
ولكن أود أن استخدام بدلا من التسميات، والسيطرة، مثل هذا:
<ListBox ItemsSource="{Binding ElementName=thisControl, Path=ListIndexes}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:Index Item="**{Binding}**"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
وبلدي شك هو ما يتم تنفيذه في هذا الربط لإدراج هذا البند كله من المجموعة.
المحلول
وبناء الجملة لذلك هو:
<local:Index Item="{Binding}"/>
وهذا سوف اقول البيانات وظائف ملزمة لربط datacontext كامل لكل مربع القائمة البند إلى الخاصية عنصر تحكم في مؤشر بك
لا تنتمي إلى StackOverflow