我有一个Button正在查看2个组合框,以确保它们在启用之前有一个值.问题是我这样做的方式是覆盖我的主题项目中声明的默认样式.
<Button x:Name="btnOK" VerticalAlignment="Center" Content="OK" IsDefault="True" Margin="0" Click="btnOK_Click">
<Button.Style>
<Style BasedOn="{StaticResource DefaultButton}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ddlWageTypes, Path=SelectedItem}" Value="{x:Null}">
<Setter Property="Button.IsEnabled" Value="false"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=ddlJobTitles, Path=SelectedItem}" Value="{x:Null}">
<Setter Property="Button.IsEnabled" Value="false"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Run Code Online (Sandbox Code Playgroud)
我已经尝试在样式标记中添加BasedOn ="{StaticResouce MyDefaultButtonStyleName}",但它在运行时会爆炸.
错误是"'System.Windows.Style'值不能分配给对象'System.Windows.Controls.Button'的属性'Style'.只能基于具有基类型'IFrameworkInputElement'的目标类型的Style.在标记文件中的对象'System.Windows.Style'中
是否在XAML中执行此操作而不覆盖默认样式.
编辑:代码示例已更新.我在OKButtonStyle上收到错误,说"无法将元素添加到属性'Resources',因为如果属性使用显式集合标记,则该属性只能有一个子元素.对象'System.Windows.Style'在标记文件中出错"
<UserControl x:Class="UK.Budgeting.XBAP.ShiftDiff.NewFTEPremiumPaySummary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:compModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:local="clr-namespace:UK.Budgeting.XBAP.ShiftDiff">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CellTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<Style TargetType="{x:Type Button}" x:Key="OKButtonStyle" BasedOn="{StaticResource DefaultButton}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ddlWageTypes, Path=SelectedItem}" Value="{x:Null}">
<Setter Property="Button.IsEnabled" Value="false"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=ddlJobTitles, Path=SelectedItem}" Value="{x:Null}">
<Setter Property="Button.IsEnabled" Value="false"/>
</DataTrigger>
</Style.Triggers> …Run Code Online (Sandbox Code Playgroud) 我工作的公司有几个客户.我目前正在两个.net项目之间分配时间.对于客户端AI需要Visual Studio 2008,SQL Server 2008和3.5框架.对于Client B 2005版本/ 2.0 Framework.
该公司的其他人正在使用Microsoft Virtual PC来保持开发环境的独立性.
你有什么建议?
附加信息: 我看到的主要好处是您可以与任何人共享您的虚拟机设置.这允许新开发人员直接进入项目,而无需花费半天时间来设置新的开发环境及其所有特性.