WPF UI grid setting and UI control C#

 

1.Grid column vilibled

 IsVisible="{Binding DataContext.EdocGridColumnIsVisibled, RelativeSource={RelativeSource AncestorType={x:Type local:EdocView }}}"

DataContext 是指上面图片画蓝色框框的,

EdocView :是当前XML的名字。

2.UI 由control 组成

 1》create control

     

[Export]
[PartCreationPolicy(CreationPolicy.NonShared)]
public partial class EdocView : UserControl
{
public EdocView()
{
RegionContext.GetObservableContext(this).PropertyChanged += OnPropertyChanged;
InitializeWhenVisibleBehavior.Initialize(this);
}

private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// var jobModel = RegionContext.GetObservableContext(this).Value as JobModel;

JobModel jobModel = new JobModel();
var awbModel = RegionContext.GetObservableContext(this).Value;
ViewModel.ViewCategory = "";
if (awbModel is OtherServicesPreparationModel)
{
#region OtherServicesPreparationModel
var model = (OtherServicesPreparationModel)awbModel;
model.PropertyChanged += model_PropertyChanged;
jobModel = new JobModel()
{
Id = model.JobId,
Biztype = model.BizType,
ShipmentType = model.ShipmentType,
MasterNo = model.AwbModel.MasterNo,
};
#endregion
}

}

}

 

2>单独创建一个class

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.MefExtensions.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Prism.Modularity;

namespace Kerry.FMS.App.UI.Common
{
[ModuleExport(typeof(CommonModule))]
public class CommonModule : IModule
{
[Import]
public IRegionManager RegionManager { get; set; }

public void Initialize()
{
RegionManager.RegisterViewWithRegion("CommonEdiRegion", typeof(EdiView));
RegionManager.RegisterViewWithRegion("CommonEdocRegion", typeof(EdocView));

}
}
}

3>在UI 书写

<StackPanel Height="200" Width="700" Name="eDoc_Details" Visibility="{Binding IseDoc_DetailsVisibility,Mode=TwoWay}" VerticalAlignment="Top" Margin="40,-35,240,0">

<ContentControl regions:RegionManager.RegionName="CommonEdocRegion"
regions:RegionManager.RegionContext="{Binding Path=InvoiceAPSearchDTOModel,Mode=TwoWay}"
Name="edocRegion" />
<!--IsEnabled="{Binding IsViewOnly, Converter={StaticResource InvertedBooleanConverter}}"-->
</StackPanel>
</Grid>
</UserControl>

 

InvoiceAPSearchDTOModel==>是ViewModel 的参数

posted on 2016-03-04 14:14  kyle.hdk  阅读(244)  评论(0编辑  收藏  举报

导航