A UWP ComboBox is generating a StackOverflowException.
<Grid Name="CutoutsGrid"
<ListView
<ComboBox
ItemsSource="{x:Bind CutoutsList}"
SelectedItem="{x:Bind CutShape,Mode=TwoWay}"
/>
</ListView>
</Grid>
CutShape and CutoutsList are defined in the ViewModel
public class ViewModel : ViewModelBase
{
string _CutShape = default(string);
public string CutShape { get { return _CutShape; } set { Set(ref _CutShape, value); } }
public List<Cutout> CutoutsList { get { return MatboardService.GetCutoutsList(); } }
CutoutsList returns 5 cutouts to choose from.
public class Cutout : BindableBase
{
string _ItemCode = default(string);
public string ItemCode { get { return _ItemCode; } set { Set(ref _ItemCode, value); } }
string _ItemDescription = default(string);
public string ItemDescription { get { return _ItemDescription; } set { Set(ref _ItemDescription, value); } }
decimal _MinutesLabor = default(decimal);
public decimal MinutesLabor { get { return _MinutesLabor; } set { Set(ref _MinutesLabor, value); } }
}
The StackOverflowException occurs in Page.g.cs
public static void Set_Windows_UI_Xaml_Controls_Primitives_Selector_SelectedItem(global::Windows.UI.Xaml.Controls.Primitives.Selector obj, global::System.Object value, string targetNullValue)
{
if (value == null && targetNullValue != null)
{
value = (global::System.Object) global::Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(global::System.Object), targetNullValue);
}
obj.SelectedItem = value;
}
In this block value == ""
and targetNullValue == null
. The exception occurs on the line obj.SelectedItem = value;
Although the ComboBox is in a ListView in a Grid, the exception occurs on the first call to
public List<Cutout> CutoutsList { get { return MatboardService.GetCutoutsList(); } }
However that is followed by many (I counted 60 before I stopped counting) calls to
Set_Windows_UI_Xaml_Controls_Primitives_Selector_SelectedItem
Why is this ComboBox causing a StackOverflowException?