Wednesday, February 10, 2010

How to set Enum type as ItemsSource?

Hi,

Here is the simple way to bind the Enum types as ItemsSource in items control.

<Window x:Class="DoubleTextBoxSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DoubleTextBoxSample"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ObjectDataProvider x:Key="itemsFromEnum" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Orientation"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>

<StackPanel>
<syncfusion:CheckListBox ItemsSource="{Binding Source={StaticResource itemsFromEnum}}">
</syncfusion:CheckListBox>
</StackPanel>
</Window>


Just bound object provider instance with Syncfusion's CheckListbox ItemsSource property and got cool result.





Thanks,
Venugopal.

No comments:

Post a Comment