繁体   English   中英

从System.Type转换为实际对象

[英]convert from System.Type to the actual object

这就是我所拥有的:

<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语句中,如果已更改的单元格是“ Station”,我想将其他设备列表加载到“设备”列中。 这可能是我设置代码的方式吗?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM