列变更,EnumDataItemStackClassTypeList数据源是枚举配置,实时查询到VM缓存的,如果是定义的枚举就不用这个麻烦了,直接在对象里面获取枚举值匹配,即
public string ApplyStatusName
{
get { return EnumHelper.GetDescriptionByValue<StockClassApplyStatusEnum>(ApplyStatus); }
}
问题是这个枚举是后台实时查询的,且类型不是int型,不能调用,于是只能走另外方法
页面控件使用如下
<c1:Column Header="变更前类型" Binding="{Binding OldTypeName, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" ColumnName="OldTypeName" Width="180" TextWrapping="True">
<c1:Column.CellTemplate>
<DataTemplate >
<TextBlock Cursor="Hand" Margin="4,0" Text="{Binding OldTypeName }"/>
</DataTemplate>
</c1:Column.CellTemplate>
<c1:Column.CellEditingTemplate>
<DataTemplate>
<c1:C1ComboBox BorderThickness="0" Style="{StaticResource StackPanel-C1ComboBox-Multiple}" Width="120" IsDropDownOpen="True"
Margin="0" SelectedValue="{Binding OldType,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True }"
DisplayMemberPath="Name" SelectedValuePath="Code" SelectedItemChanged="C1ComboBox_SelectedItemChanged"
ItemsSource="{Binding Path=DataContext.EnumDataItemStackClassTypeList,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=basicControls:SingletoneWin}}"/>
</DataTemplate>
</c1:Column.CellEditingTemplate>
</c1:Column>
行事件加载
private new void FlexGrid_LoadedRows_RowIndex(object sender, EventArgs e)
{
base.c1FlexGrid_LoadedRows(sender, e);
var vm = DataContext as StockClassParamChangeApplyFormVM;
ViewHelper.SetRowIndexNoPage(sender as C1FlexGrid);
if (CfgReviewItem == null) return;
if (CfgReviewItem.Rows.Count > 0)
{
foreach (var row in CfgReviewItem.Rows)
{
var model = row.DataItem as StockClassParamChangeDetailLogModel;
if (model == null) continue;
vm.CurrentDetailItem = model;
vm.ChangeEunmValue();
}
}
}
列属性变更,获取到控件的操作行,针对操作行的列进行属性值变更,列用的下拉框控件
private void C1ComboBox_SelectedItemChanged(object sender, C1.WPF.PropertyChangedEventArgs<object> e)
{
var vm = DataContext as StockClassParamChangeApplyFormVM;
if (vm == null)
{
return;
}
var testInfo = CfgReviewItem.HitTest(Mouse.GetPosition(CfgReviewItem));
if (testInfo.Row > -1)
{
var selectedItem = CfgReviewItem.Rows[testInfo.Row].DataItem as StockClassParamChangeDetailLogModel;
vm.CurrentDetailItem = selectedItem;
vm.ChangeEunmValue();
}
}
//vm中处理,因为要刷新属性
public void ChangeEunmValue()
{
if (CurrentDetailItem != null)
{
int? changeTypes = CurrentDetailItem.ChangeType;
string newTypes = CurrentDetailItem.NewType;
string oldTypes = CurrentDetailItem.OldType;
if (changeTypes.HasValue) {
foreach(EnumDataItemModel model in EnumDataItemStackClassChangeTypeList) {
if (model.Code.Equals(Convert.ToString(changeTypes))) {
CurrentDetailItem.ChangeTypeName = model.Name;
}
}
}
if (!string.IsNullOrEmpty(newTypes))
{
foreach (EnumDataItemModel model in EnumDataItemStackClassTypeList)
{
if (model.Code.Equals(Convert.ToString(newTypes)))
{
CurrentDetailItem.NewTypeName = model.Name;
}
}
}
if (!string.IsNullOrEmpty(oldTypes))
{
foreach (EnumDataItemModel model in EnumDataItemStackClassTypeList)
{
if (model.Code.Equals(Convert.ToString(oldTypes)))
{
CurrentDetailItem.OldTypeName = model.Name;
}
}
}
RaisePropertyChanged(() => CurrentDetailItem);
}
}