Xaml UWP组合框中的StackOverflowException

Xaml UWP组合框中的StackOverflowException,xaml,uwp,uwp-xaml,Xaml,Uwp,Uwp Xaml,UWP组合框正在生成StackOverflowException <Grid Name="CutoutsGrid" <ListView <ComboBox ItemsSource="{x:Bind CutoutsList}" SelectedItem="{x:Bind CutShape,Mode=TwoWay}" /> </ListView> </Grid

UWP组合框正在生成StackOverflowException

<Grid Name="CutoutsGrid"
    <ListView 
        <ComboBox 
            ItemsSource="{x:Bind CutoutsList}"
            SelectedItem="{x:Bind CutShape,Mode=TwoWay}"
        />
    </ListView>
</Grid>
StackOverflowException出现在第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;
}
在此块中,
value==”
targetNullValue==null
。异常发生在
obj.SelectedItem=value行

尽管ComboBox位于网格中的ListView中,但在第一次调用

public List<Cutout> CutoutsList { get { return MatboardService.GetCutoutsList(); } }

为什么这个组合框会导致StackOverflowException?

您很可能通过删除双向绑定或使用旧的绑定方法来实现这一点

例如:

<Grid Name="CutoutsGrid"
    <ListView 
        <ComboBox 
            ItemsSource="{Binding CutoutsList}"
            SelectedItem="{Binding CutShape,Mode=TwoWay}"
        />
    </ListView>
</Grid>

我不确定Set方法在做什么,但您很可能可以去掉ref关键字。

只需更改为Binding即可。感谢@Mikael Koskinen stackoverflowexception也会因DependencyProperties而引发,原因可能与此相同。旧装订作品
public List<Cutout> CutoutsList { get { return MatboardService.GetCutoutsList(); } }
Set_Windows_UI_Xaml_Controls_Primitives_Selector_SelectedItem
<Grid Name="CutoutsGrid"
    <ListView 
        <ComboBox 
            ItemsSource="{Binding CutoutsList}"
            SelectedItem="{Binding CutShape,Mode=TwoWay}"
        />
    </ListView>
</Grid>
public string CutShape 
{ 
  get { return _CutShape; } 
  set 
  { 
    if (_CutShape != value)
       Set(ref _CutShape, value);  
  }
}