mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-09 23:43:28 +02:00
Add how to bind enum article (#1056)
* 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]>
This commit is contained in:
co-authored by
Tom Dykstra
parent
dd902d2e9c
commit
3885aab154
+26
@@ -0,0 +1,26 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user