gpt4 book ai didi

.net - 样式不适用于 Win7 x32 (.Net 4.0)

转载 作者:行者123 更新时间:2023-12-01 13:56:11 24 4
gpt4 key购买 nike

我们使用自己设计的图像按钮。在我们的开发人员计算机(所有 Win 7 x64 VS 2013)上运行良好。同样在装有 Win7 x64 .Net 4.5.x 的客户计算机上。

在装有 Win 7 x32 .Net 4.0 的测试计算机上,图像按钮具有按钮的标准样式,而不是新样式。在带有 .Net 4.5 的 Win 7 x32 上它可以工作。所以我认为问题出在 .Net 版本而不是 x32 架构。

我们的图像按钮样式

<!-- Default Template -->
<Style TargetType="{x:Type con:PreparedImageButton}" BasedOn="{x:Null}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type con:PreparedImageButton}">
<Border
x:Name="_PART_BORDER"
CornerRadius="0"
BorderThickness="0"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Padding="{TemplateBinding Padding}"

Background="{DynamicResource DefaultBackground}">
<Viewbox Stretch="Uniform">
<ContentPresenter x:Name="_PART_SIGN" Content="{x:Null}" />
</Viewbox>
</Border>
<ControlTemplate.Triggers>
<!-- Background Trigger -->
<!-- Disabled Background -->
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="_PART_BORDER" Property="Background"
Value="{DynamicResource DisabledBackground}" />
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
<!-- Pushed Background -->
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="_PART_BORDER" Property="Background"
Value="{DynamicResource PushedBackground}" />
</Trigger>

<!-- Button Type Trigger -->
<!-- Next -->
<Trigger Property="ButtonType" Value="Next">
<Setter TargetName="_PART_SIGN" Property="Content" Value="{DynamicResource NextSignCanvas}" />
</Trigger>
<!-- Back -->
<Trigger Property="ButtonType" Value="Previous">
<Setter TargetName="_PART_SIGN" Property="Content" Value="{DynamicResource BackSignCanvas}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

在大多数情况下,我们为 ViewModel 使用 DataTemplate

<!-- Default ViewModel Template -->
<DataTemplate DataType="{x:Type vm:PreparedImageButtonViewModel}">
<con:PreparedImageButton ButtonType="{Binding ButtonType}"
IsVikingStyle="{Binding IsVikingStyle}"
Command="{Binding Command}"
IsEnabled="{Binding IsEnabled}"
Visibility="{Binding IsVisible, Converter={StaticResource BooleanVisibilityConverter}}"
IsCancel="{Binding IsCancel}"
IsDefault="{Binding IsDefault}"
ToolTip="{Binding ToolTip}"
Width="{DynamicResource DefaultButtonHeight}"
Padding="{DynamicResource DefaultSignPadding}"
Height="{DynamicResource DefaultButtonHeight}" />
</DataTemplate>

在窗口/用户控件中,我们将此按钮绑定(bind)到 ContentControl 上:

<ContentControl Content="{Binding ProtocolButton}" Margin="0,0,5,0" HorizontalAlignment="Right" />

知道 .Net 4.0 出了什么问题吗?

Win7 x32 .Net 4.0 Windows 7 x32 .Net 4.0Win7 x64 .Net 4.5 Windows 7 x64 .Net 4.5.1

编辑

.Net 4.0 似乎无法正确解析合并的字典。通常我们在当前项目的 Global.xaml 中合并外部词典。

如果我们使用图像按钮来执行此操作,则它不起作用。如果我们直接在 Windows/UserControl 中合并图像按钮的字典,在我们使用它们的地方,这是可行的(在 .Net 4.0 下)。

对于我们的所有其他控件,合并工作没有问题。

我们现在测试,是否存在问题,如果我们在仅使用 .Net 4.0 和 VS2010 的计算机上构建解决方案。

最佳答案

我的解决方案如下:

从 app.xaml 中删除所有资源字典并以编程方式添加它们:

关于 App.xaml.cs 的构造函数

        var item = new ResourceDictionary
{
Source = new Uri("link to a skin for example")
};
Current.Resources.MergedDictionaries.Add(item);

_appboot = new Bootstrapper();
var bootRd = new ResourceDictionary {{"bootstrapper", _appboot}};
Current.Resources.MergedDictionaries.Add(bootRd);

这应该可以解决问题。

有关该问题的信息可在此处找到: https://msdn.microsoft.com/en-us/library/ee941656(VS.100).aspx#windows_presentation_foundation_wpf

关于.net - 样式不适用于 Win7 x32 (.Net 4.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26033608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com