技术开发 频道

Visual Studio 2010 的自定义开始页

   • 创建控件项目
  在我们刚刚使用的StartPage解决方案中,添加一个Visual C#项目imccBlog,项目模板选择WPF User Control Library。项目创建完成后,为项目添加下列dll的引用:
  C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.VisualStudio.Shell.UI.dll

  通过添加此dll的引用,我们可以在XAML中执行Visual Studio的内部命令。
 
  • 编辑UserControl1.xaml
  编辑UserControl1.xaml的内容如下,以读取RSS并显示在开始页中:

<UserControl x:Class="imccBlog.UserControl1"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vs
="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.UI">
    
<Grid>
        
<Grid.Resources>
            
<XmlDataProvider x:Key="imccBlog" XPath="rss/channel" Source="http://imcc.blogbus.com/index.rdf" />
        
</Grid.Resources>
        
<Border BorderBrush="Black" BorderThickness="1" CornerRadius="10" Padding="4" Margin="0,0,0,10" >
            
<ItemsControl DataContext="{StaticResource imccBlog}" ItemsSource="{Binding XPath=item}" BorderBrush="Transparent" Padding="6" >
                
<ItemsControl.ItemTemplate>
                    
<DataTemplate>
                        
<TextBlock Margin="0,0,0,6">
                            
<Image Source="C:\Users\Public\Documents\CTPWalkthroughs\Visual Studio\Samples\Start Page\greendot.png" Height="10" Margin="0,0,5,0" />
                            
<Hyperlink Foreground="White" Command="{x:Static vs:VSCommands.Browse}" CommandParameter="{Binding XPath=link}">
                        
<TextBlock FontSize="12" Text="{Binding XPath=title}" /></Hyperlink></TextBlock>
                    
</DataTemplate>
                
</ItemsControl.ItemTemplate>
            
</ItemsControl>
        
</Border>
    
</Grid>
</UserControl>
0
相关文章