win7下没有可用于 ".xaml"的编辑器 确保已安装文件类型(.xaml)的应用程序

开始—Micorosft Visual Studio 2008—Visual Studio Tools—Visual Studio 2008 Command Prompt(右键点击,选择以管理员权限运行,不然的话不会生效)然后输入:devenv /resetskippkgs
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在WPF应用程序中,如果想要在myResources文件夹下新建名为myDictionary.xaml的资源字典文件,可以按照以下步骤操作: 1. 在 Visual Studio 中,展开项目文件夹,找到myResources文件夹,右键单击该文件夹,选择“添加” -> “新建项”。 2. 在“添加新项”对话框中,选择“WPF” -> “Resource Dictionary”,然后输入文件名“myDictionary.xaml”,点击“添加”按钮。 3. 在新建的myDictionary.xaml文件中,可以定义资源字典的内容,例如: ```xml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <SolidColorBrush x:Key="MyBrush" Color="Blue" /> <Style x:Key="MyButtonStyle" TargetType="Button"> <Setter Property="Background" Value="{StaticResource MyBrush}" /> <Setter Property="Foreground" Value="White" /> <Setter Property="Margin" Value="5" /> </Style> </ResourceDictionary> ``` 在这个例子中,定义了两个资源,一个是名为“MyBrush”的颜色刷,另一个是名为“MyButtonStyle”的样式,其中使用了刚刚定义的颜色刷。 4. 在需要使用该资源字典的XAML文件中,可以使用MergedDictionary的方式来引用该资源字典,例如: ```xml <Window x:Class="MyApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow"> <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="myResources/myDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources> <Grid> <Button Style="{StaticResource MyButtonStyle}" Content="Click me!" /> </Grid> </Window> ``` 这样,就可以在MainWindow中使用myDictionary.xaml中定义的资源了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值