I have a combox box in WPF. I want the combobox values to be the numbers 1-8. I want the selected value at startup to be 2. The code below gives me a blank combobox, with the following error:
"Cannot find resource named 'GeneralLineWidthRange'. Resource names are case sensitive."
Why can't the xaml find the GeneralLineWidthRange property in the code-behind?
XAML:
<ComboBox
ItemsSource="{Binding Source={StaticResource GeneralLineWidthRange}}"
SelectedItem="CurrentLineWidth">
</ComboBox>
Code-Behind:
public partial class PreferencesTabGeneral : UserControl
{
IList<int> generalLineWidthRange = new List<int>();
int currentLineWidth = 2;
public PreferencesTabGeneral()
{
InitializeComponent();
for (int i = 1; i < 9; i++)
generalLineWidthRange.Add(i);
DataContext = this;
}
public IList<int> GeneralLineWidthRange
{
get
{
return generalLineWidthRange;
}
set
{
generalLineWidthRange = value;
}
}
public int CurrentLineWidth
{
get
{
return currentLineWidth;
}
set
{
currentLineWidth = value;
}
}
}