06 2012 档案
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspxMEF 通过诊断拒绝的功能,即跟踪功能。有以下3种方式:在 IDE 中,可从输出窗口跟踪所有拒绝消息,不过也可以从任何有效的跟踪侦听器跟踪这些消息。在调试中,查看部件。 container.Catalog.Parts在命令行处诊断。可下载 MEFX.exe 进行诊断。
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx有时,一个部件可能一个缺少的导入.在进行组合时,不会触发异常,只是该部件不会进行组合而已。
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx允许部件在系统中出现新的匹配导出时自动更新其导入。[Export]public class ViewFactory{ [ImportMany(AllowRecomposition=true)] IEnumerable<Lazy<IView, IViewMetadata>> Views { get; set; } public IEnumerable<View>GetViews(ViewTypes viewType) { return Views.Whe
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx System.Lazy<T>: 可延迟实例的实例化,直至访问 Lazy 的 Value 属性.Lazy<T,TMetadata> : 允许在不实例化基础导出的情况下访问导出元数据。TMetadata 是元数据视图类型。元数据视图是接口,用于定义对应于所导出元数据中的键的只读属性。访问元数据属性时,MEF 将动态实现 TMetadata,且将基于导出提供的元数据来设置值。[Export]public class ViewFactory{ [ImportMany]
阅读全文
摘要:[MetadataAttribute]//指明 类ExportViewAttribute 将提供元数据。将类的所有公共属性输出为元数据。这里只有一个ViewType 属性。[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] //这指定该属性仅对类有效,且只能存在一个 ExportView 特性???public class ExportViewAttribute : ExportAttribute{ public ExportViewAttribute() : base(typeof(IView))// Export(
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx元数据可以用来区分导出。区分导出也可以用其它的技术,如在每个部件中添加一个属性来区分。但是,使用原数据有它的优点:部件的实例化可延迟到需要时进行,这可节约资源并提高性能。[ExportMetadata("ViewType", "SalesOrder")] //键值对[Export(typeof(IView)]public partial class SalesOrderView : UserControl, IView{}//以上代码直接使用字符串
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx默认情况下,容器中的所有部件实例都是单例,因而由在容器中导入它们的所有部件共享。因此,SalesOrderView 和 ViewFactory 的所有导入程序都将获得同一实例。在很多情况下需要这样,因为这样便无需拥有其他组件所依赖的静态成员。但是,有时每个导入程序都需要获取自己的实例,例如用于同时在屏幕上查看多个 SalesOrderView 实例。MEF 中的部件创建策略可以是以下三个值之一:CreationPolicy.Shared、CreationPolicy.NonShared
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx[Export]public class ViewFactory{ [ImportMany] IEnumerable<IView> Views { get; set; }}[Export(typeof(IView))]public partial class SalesOrderView : UserControl, IView{}//in a contract assemblypublic interface IView { }MEF 还支持使用具体集合(如 Observa
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx原文如下, 翻译得有点晕:开始创建约定时,需要能够将这些约定部署到第三方。实现此目的的常用方法是使某个约定程序集包含扩展程序将实现的约定的接口。该约定程序集成为部件将引用的 SDK 形式。常见模式是采用“应用程序名称 + .Contracts”的形式命名约定程序集,如 SalesOrderManager.Contracts。是指经常用的 typeof()???
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx[Export (typeof(ISalesOrderView))][Export (typeof(UserControl))]public partial class SalesOrderView : UserControl, ISalesOrderView{ ...}还没使用过这种情况!!!
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx大多数都是同接口实现 MEF 的。适用 “导出类” 的情况还是比较少的。public interface ISalesOrderView{}[Export(typeof(ISalesOrderView))]public partial class SalesOrderView : UserControl, ISalesOrderView{ ...}[Export]public class ViewFactory{ [Import] ISalesOrderView OrderView{ g
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx*注意 这里是“属性导出”要跟前面的文章(2) “属性导入”对比看。public class Loggerpart{ [Export] public ILog Logger { get { return LogManager.GetLogger("Logger"); }//LogManager.GetLogger是“非MEF程序”,通过属性封装成 MEF 程序了。 }}属性导出在其功能方面如同瑞士军刀,使 MEF 可与其他对象配合良好。您会发现,在将 MEF 集成到现
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx启动 MEF 涉及以下几个步骤:添加需要容器创建的约定的导入。创建 MEF 用于发现部件的目录。创建组合部件实例的容器。通过对容器调用 Composeparts 方法并传入具有导入的实例,来进行组合。DirectoryCatalog catalog = new DirectoryCatalog(".");CompositionContainer container = new CompositionContainer(catalog);container.Compos
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx导入有2种方式: (1)通过属性和字段导入public class ViewFactory{ [Import] public SalesOrderView OrderView { get; set; }}(2)通过构造函数导入public class ViewFactory{[ImportingConstructor] public ViewFactory(SalesOrderView salesOrderView) { }}通过构造函数进行导入(通常称为构造函数注入),使用导入...
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx导出类: 使用者不需要写实例化代码. [Export]public partial class SalesOrderView : UserControl{ public SalesOrderView() { InitializeComponent(); }}
阅读全文
摘要:在 .NET 4 中使用托管可扩展性框架构建可组合的应用程序 1. 基本概念可组合的部件、导出、 导入、约定、 组合2. MEF 特性化编程模型 这里的"特性", 也称为"属性". 如 [Export] [Import]等. "特性化编程模型" 只是 MEF 支持的众多可能的编程模型之一。MEF 的核心 API 完全与特性无关
阅读全文
摘要:可能的原因:1. Web 没有引用 Wcf.Web项目.2. Web 的配置文件少了 connectionstring
阅读全文
摘要:CollectionViewSource 好像没有删除的操作. ObservableCollection类既实现了INotifyPropertyChanged接口,又实现了INotifyCollectionChanged接口。使用ObservableCollection类不但可以实现Add、Remove、Clear和Insert操作,还可以触发PropertyChanged事件。虽然上述的ObservableCollection很好用而且继承了INotifyPropertyChanged接口,有些时候我们需要对集合进行排序、过滤、分页等操作,这个时候就需要用ICollectionView接口,
阅读全文
摘要:http://www.cnblogs.com/webabcd/archive/2010/10/21/1857199.html
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/library/cc903947(v=vs.95)
阅读全文
摘要:<sdk:DataGridTemplateColumn Width="80"><sdk:DataGridTemplateColumn.CellTemplate><DataTemplate><Button Content="Delete" Click="DeleteButton_Click" /></DataTemplate></sdk:DataGridTemplateColumn.CellTemplate></sdk:DataGridTemplateColu
阅读全文
摘要:Deleting the selected row(s) requires you to get the bound collection or collection view and enumeratethrough the SelectedItems property of the DataGrid, removing the corresponding item from the boundcollection/collection view. This is can be somewhat of a messy process due to removing items in anen
阅读全文
摘要:The final (and generally most user-friendly) method is to automatically maintain an empty row as thelast row in the DataGrid. The user can enter data for a new item in this row, and the DataGrid shouldautomatically add a new empty row once they do. Sadly, there is no built-in feature like this in th
阅读全文
摘要:the DomainDataSourceView class doesn’t have an Insert method, but if you have areference to the bound collection that does support this method (such as an ObservableCollection) andwant to insert a new row after the currently selected row, you can use the following codeObservableCollection<Product
阅读全文
摘要:DomainDataSourceView view = productDataGrid.ItemsSource as DomainDataSourceView;Product newProduct = new Product();view.Add(newProduct);// Scroll the first cell of the new row into view and start editingproductDataGrid.Focus();productDataGrid.SelectedItem = newProduct;productDataGrid.CurrentColumn =
阅读全文
摘要:bool hasChanges = ((Entity)ProductsDataForm.CurrentItem).HasChanges;
阅读全文
摘要:object element = FocusManager.GetFocusedElement();
阅读全文
摘要:1. 要求: OOB, 而且要提升信任. dynamic excel = AutomationFactory.CreateObject("Excel.Application"); excel.Visible = true; excel.workbooks.Add(); dynamic sheet = excel.ActiveSheet; dynamic cell = null; int i = 1; foreach (AGC工程 c in dataGrid1.ItemsSource) { cell = sheet.Cells[i /*row*/, 1 /*col*/]; c
阅读全文
摘要:1. 视频 http://www.silverlight.net/learn/data-networking/data-controls/dataform-control
阅读全文
摘要:http://visualstudiogallery.msdn.microsoft.com/6a9f4f1a-579d-4a76-9d3a-70dd3339cfd6/
阅读全文
摘要:http://www.cnblogs.com/Mainz/archive/2011/10/04/2198924.html
阅读全文
摘要:1. 使用Convertor<RadioButton Content="type 1" IsChecked="{Binding Path=MyTypeProperty, Mode=TwoWay, Converter={StaticResource ConvertMyType}, ConverterParameter=type1}" /> <RadioButton Content="type 2" IsChecked="{Binding Path=MyTypeProperty, Mode=TwoWay, Co
阅读全文
摘要:1. 错误 System.ServiceModel.DomainServices.Client.LoadOperation op = ctx.Load(ctx.GetCustomersQuery()); 正确 var op = ctx.Load(ctx.GetCustomersQuery()); 或 System.ServiceModel.DomainServices.Client.LoadOperation<Customer> op = ctx.Load(ctx.GetCustomersQuery());2 <sdk:DataGrid AutoGenerateColumns
阅读全文
摘要:http://www.cnblogs.com/Ken-Cai/admin/Silverlight%20Multi%20File%20Uploader
阅读全文
摘要:public const string CustomerListPropertyName = "CustomerList"; private IEnumerable<Customer> _customerList; public IEnumerable<Customer> CustomerList { get { return _customerList; } set { if (_customerList == value) return; var oldValue = _customerList; _customerList = value; /
阅读全文
摘要:Menu and Context Menu for Silverlight 4.0http://sl4popupmenu.codeplex.com/
阅读全文