【问题标题】:Error with combobox binding using caliburn micro使用 caliburn micro 的组合框绑定错误
【发布时间】:2014-01-11 15:07:11
【问题描述】:

嗨,我有这个组合框:

<ComboBox x:Name="Orders" Width="150" Grid.Row="0"
          HorizontalAlignment="Left"
          SelectedItem="{Binding Order}" Margin="3" />

这是视图模型中的代码:

class MyFerViewModel : Screen, IMyFerViewModel
    {

        private string[] orders = { "ABC", "CDC", "EFR", "ACER" };

        private string order = "ABC";       

        public string[] Orders { get { return orders; } }

        public string Order
        {
            get { return order; }
            set
            {
                if (value != order)
                {
                    order = value;
                    Reorder();
                }
            }
        }

[..]

为什么当我看不到视图并在引导程序中出现此错误时?

“找不到合约 ABC 的任何实例。”

【问题讨论】:

    标签: c# wpf binding combobox caliburn.micro


    【解决方案1】:

    您需要将ItemsSource 绑定到组合框并进一步绑定SelectedItem

    <ComboBox x:Name="Orders" 
              Width="150" Grid.Row="0" 
              HorizontalAlignment="Left" 
              ItemsSource="{Binding Orders}"
              SelectedItem="{Binding Order}"          
              Margin="3" />
    

    希望对你有帮助..

    【讨论】:

      猜你喜欢
      • 2011-06-20
      • 1970-01-01
      • 2016-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-24
      • 2012-10-12
      • 2018-07-29
      相关资源
      最近更新 更多