[英]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.