mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 16:06:07 +02:00
* add how to article * Fix lint * Fix the code example * Add missing code * Update how-to-bind-to-an-enumeration.md * Update dotnet-desktop-guide/net/wpf/data/how-to-bind-to-an-enumeration.md Co-authored-by: Tom Dykstra <[email protected]> Co-authored-by: Tom Dykstra <[email protected]>
27 lines
1.1 KiB
XML
27 lines
1.1 KiB
XML
<Window x:Class="ArticleExample.BindEnumFull"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
|
SizeToContent="WidthAndHeight"
|
|
Title="Enum binding">
|
|
<Window.Resources>
|
|
<ObjectDataProvider x:Key="EnumDataSource"
|
|
ObjectType="{x:Type sys:Enum}"
|
|
MethodName="GetValues">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="HorizontalAlignment" />
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
</Window.Resources>
|
|
|
|
<StackPanel Width="300" Margin="10">
|
|
<TextBlock>Choose the HorizontalAlignment value of the Button:</TextBlock>
|
|
|
|
<ListBox Name="myComboBox" SelectedIndex="0"
|
|
ItemsSource="{Binding Source={StaticResource EnumDataSource}}"/>
|
|
|
|
<Button Content="I'm a button"
|
|
HorizontalAlignment="{Binding ElementName=myComboBox, Path=SelectedItem}" />
|
|
</StackPanel>
|
|
</Window>
|