如何自定义Visual Studio 2010 RC StartPage最近的项目

问题描述:

我想玩弄自定义visual studio 2010 rc开始页面最近的项目。对于我的想法,我需要自定义数据源/数据绑定,但我无法找到信息来自哪里。如何自定义Visual Studio 2010 RC StartPage最近的项目

<ScrollViewer Grid.Row="1" HorizontalAlignment="Stretch" 
    Style="{DynamicResource StartPage.ScrollViewerStyle}" 
    VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto"> 
    <sp:MruListBox 
     DataContext="{Binding Path=RecentProjects}" 
     ItemsSource="{Binding Path=Items}" 
     Background="Transparent" 
     BorderThickness="0" 
     AutomationProperties.AutomationId="MruList"/> 
</ScrollViewer> 

任何人都可以指向正确的方向吗?我发现它对最近的项目有约束力,但它来自哪里?

+0

您是否曾经找到每个最近的项目源项目包含的属性的描述? – 2012-02-10 18:04:39

我找不到任何有关此的真实文档。我猜你知道VS Docs,但它甚至没有划伤表面。

由于在绑定中使用了RecentProjects属性,因此应该有一个暴露此类属性的类型(或ICustomTypeDescriptor的实现,请参阅MSDN Magazine)。对TeamFoundationClientSupported“属性”也有绑定。

我在Microsoft.VisualStudio.Shell.UI.Internal中找到了一个名为TeamFoundationClientSupported的属性,该类名为Microsoft.VisualStudio.PlatformUI.StartPageDataSource,但它是私有的,因此不能在绑定中使用。 这个类的构造函数中含有相当多的线路是这样的:

base.AddBuiltInProperty(StartPageDataSourceSchema.CustomizationEnabledName, GetUserSetting(StartPageDataSourceSchema.CustomizationEnabledName, false)); 
    ... 
base.AddBuiltInProperty(StartPageDataSourceSchema.TeamFoundationClientSupportedName, this.TeamFoundationClientSupported); 
    ... 
base.AddBuiltInProperty(StartPageDataSourceSchema.RecentProjectsDataSourceName, source3); 
    ... 

最后2很有意思:他们“增加一个内置属性”叫TeamFoundationClientSupported和RecentProjects ...

在展望此方法的实现显示了一个简单的字典,其中包含基于属性名称(第一个参数)的键和值作为第二个参数的键。此字典由Microsoft.Internal.VisualStudio.PlatformUI.UIDataSource中名为EnumProperties的方法使用。通过使用链,我们到达一个名为Microsoft.Internal.VisualStudio.PlatformUI.DataSource的类(在Microsoft.VisualStudio.Shell.10.0中),该类实现ICustomTypeDescriptor。因此,它解释了绑定系统如何找到这些属性。我还没有找到DataSource类型描述符如何链接到StartPageDataSource类,但至少我们可以知道StartPageDataSource构造函数中支持的属性列表。

+0

谢谢约翰。我认为这和现在要做的一样好。真的,我只想扩展起始页面最近的项目,以便能够重新命名项目(特别是解决方案)。这对任何在scm主线工作的人都很有用。至少我知道我会得到大量的使用它:) – devlife 2010-03-25 01:54:48

+0

我明白上面的解决方案是在说什么,但我仍然不明白我如何可以得到的属性列表上可用RecentProjectDataSource。有没有什么办法可以访问这个代码? – 2011-06-20 06:19:01

+0

我还没有读过它们,但也许这些文章将有助于:http://www.7388.info/index.php/article/wpf/2011-06-17/18130.html和http://www.7388。 info/index.php/article/wpf/2011-06-15/18024.html – Timores 2011-06-20 20:21:43