fsprojects / FsXaml

F# Tools for working with XAML Projects
http://fsprojects.github.io/FsXaml/
MIT License
171 stars 48 forks source link

Binding to SelectedItem property of ComboBox throws XamlDuplicateMemberException #56

Closed easymorph closed 7 years ago

easymorph commented 7 years ago

Description

Binding in XAML to SelectedItem or SelectedValue or SelectedIndex of a Combobox throws XamlDuplicateMemberException.

Repro steps

Create XAML with a ComboBox in which ItemSource and SelectedItem are bound to some model properties. E.g. <ComboBox ItemsSource="{Binding AllItems}" SelectedItem="{Binding CurrentItem}" / >

ViewModel has properties defined as:

let items = [|"One"; "Two"|]
member this.AllItems with get() = items
member this.CurrentItem with get() = items.[1]

Expected behavior

No exceptions thrown. The combobox has two items with second item selected.

Actual behavior

Exception on creating instance of the view type defined as XAML<"View.xaml">: System.Xaml.XamlDuplicateMemberException was unhandled Message: An unhandled exception of type 'System.Xaml.XamlDuplicateMemberException' occurred in System.Xaml.dll Additional information: 'SelectedItem' property has already been set on 'ComboBox'.

Known workarounds

Setting selected item using code-behind works as expected.

Related information

easymorph commented 7 years ago

The CurrentItem property expected to have a setter. Please close the issue.