Reputation: 1
Helo,i am using mvvm...i have a combobox,here is the xaml code
<ComboBox Grid.Column="4" Grid.Row="3" Height="23" SelectedValue="{Binding Path=Percentage, Mode=TwoWay}" SelectedValuePath="Percentage" HorizontalAlignment="Left" Margin="18,7,0,0" Name="comboBox1" VerticalAlignment="Top" Width="144">
<ComboBoxItem Content="12"></ComboBoxItem>
<ComboBoxItem Content="13"></ComboBoxItem>
<ComboBoxItem Content="14"></ComboBoxItem>
<ComboBoxItem Content="15"></ComboBoxItem>
<ComboBoxItem Content="16"></ComboBoxItem>
<ComboBoxItem Content="17"></ComboBoxItem>
<ComboBoxItem Content="18"></ComboBoxItem>
<ComboBoxItem Content="19"></ComboBoxItem>
<ComboBoxItem Content="20"></ComboBoxItem>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding PercentageChangedCommand}"
CommandParameter="{Binding Percentage, ElementName=comboBox1}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
when am accessing the selected value to a method in the combobox it only shows
system.windows.Controls.comboboxitem:12
It doesn't set that value.. help me plEASE
Upvotes: 0
Views: 371
Reputation: 599
SelectedValuePath="Percentage"
Try removing all the ComboBoxItem declarations, expose the following property from the ViewModel and bind to it ItemsSource={Binding Items}
public List<int> Items
{
get { return Enumerable.Range(1, 100).ToList(); }
}
Upvotes: 1