Click here to Skip to main content
14,735,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying, without success, to fill a combobox with string representation of enums and bind to data. I'm able to do this in a dialog but when I try to apply the same logic to a combobox embedded in a gridview it doesn't work. I've been banging my head against the wall on this one for the better part of a day. Any help would be greatly appreciated. Thank you.

Up top in both files:

xmlns:converters="clr-namespace:tpx.MMaker.MVVM.Net.PositionProfile.Converter"
             xmlns:Enums="clr-namespace:tpx.MMaker.MessageModel.Net.Enums"


Working code:


ComboBox Grid.Row="4" Grid.Column="1" ItemsSource="{Binding SkewTypes}"
SelectedValue="{Binding optionClass.UsePrintSkew, Converter={StaticResource enumDescriptionConverter},
ConverterParameter='tpx.MMaker.MessageModel.Net.Enums.SkewTypes, tpx.MMaker.MessageModel.Net'}"

Non working code with line I want to fix commented out:

<ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header=" Account " Width="auto">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=Account}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                       <GridViewColumn Header=" Contract " Width="auto">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=Contract}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header=" Formula " Width="auto">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <!--<ComboBox ItemsSource="{Binding ModelFormulas}" SelectedValue="{Binding optionClass.Formula, Converter={StaticResource enumDescriptionConverter}, ConverterParameter='tpx.MMaker.MessageModel.Net.Enums.ModelFormulas, tpx.MMaker.MessageModel.Net'}" />-->
                                    <TextBox Text="{Binding Path=Formula}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
Posted
Comments
mudit_malhotra 30-Sep-14 10:46am
   
is ModelFormulas a property in the item of itemSource of grid ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900