从System.Type转换为实际对象

时间:2015-04-28 16:47:50

标签: c# wpf infragistics

这就是我所拥有的:

<usercontrol>
    <usercontrol.resources>
            <Style x:Key="NorthStationStyle" TargetType="{x:Type igWPF:XamComboEditor}">
                <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=DataContext.StationListA}"/>
            </Style>
    </usercontrol.resources>

    <XamDataGrid CellChanged="NorthDataGrid_OnCellChanged" FieldLayoutInitialized="OnFieldLayoutInitialized" />
 </usercontrol>  

    Code control code behind:
    private void OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e)
            {
     e.FieldLayout.Fields["Equipment"].Settings.EditorStyle = Resources["NorthStationStyle"] as Style;
    }

    NorthDataGrid_OnCellChanged(object sender, CellChangedEventArgs e){

    if(e.Cell.Field.Name == "Station")
     //here I want to re-bind a different list to the ItemsSource property       

    }

在单元格中更改了if语句,如果更改的单元格是&#34; Station&#34;我想在“设备”列中加载不同的设备列表。这可能是我设置代码的方式吗?

1 个答案:

答案 0 :(得分:1)

假设XamComboEditor x = Activator.CreateInstance(comboType) as XamComboEditor引用的类(在本例中为System.Type)具有默认构造函数,

XamComboEditor应该有效。