【问题标题】:XBAP: Missing texts in published versionXBAP:已发布版本中缺少文本
【发布时间】:2010-11-15 21:38:37
【问题描述】:

发布我的 XBAP 应用程序后,我丢失了所有(或部分)文本块。它看起来像这样:

按钮应该有标签,主屏幕上应该有各种文本块。

让事情变得更奇怪:

  • 此应用程序完美运行 调试时。
  • 并非所有文本总是丢失,有些文本有时会出现 时间。
  • 我实现了一个不断变化的 LayoutTransform 来调整 托管浏览器。在某些尺寸上,所有 (或一些)文本突然出现。 (使用固定的 LayoutTransform, 有时文本也会丢失)。相反,更改为 RenderTransform 不会更改此行为。也不会删除调整大小。
  • 我正在绘制的图表中的文本丢失。他们被拉进 自定义控件中的 OnRender。
  • 此行为仅在某些计算机上可见。我怀疑他们都安装了.NET 4.0。为 .NET 4.0 编译时,一切都很好,但由于 .NET 4.0 尚未广泛安装,我宁愿为 .NET 3.5 编译

任何想法可能导致这种情况?请询问您是否需要更多信息!谢谢!

编辑: 我做了一个小项目来重现这个错误。你可以找到它发布的here。请注意,此错误似乎只影响 .NET 4.0。

从 WPF 浏览器应用程序开始,这是我在 Page1.xaml 中的代码

<Page x:Class="BugDemo.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Grid x:Name="LayoutRoot">
        <TextBlock FontSize="35" Text="Vanishing Text" />
        <Grid.LayoutTransform>
            <ScaleTransform />
        </Grid.LayoutTransform>
    </Grid>
</Page>

代码隐藏:

public partial class Page1 : Page
{
    public Page1()
    {
        InitializeComponent();    
        this.Loaded += AppPage_Loaded;
    }

    public double Scale
    {
        get { return ((ScaleTransform)this.LayoutRoot.LayoutTransform).ScaleX; }
        set
        {
            ((ScaleTransform)this.LayoutRoot.LayoutTransform).ScaleX = value;
            ((ScaleTransform)this.LayoutRoot.LayoutTransform).ScaleY = value;
        }
    }

   void AppPage_Loaded(object sender, RoutedEventArgs e)
    {
        App.Current.MainWindow.SizeChanged += (o, args) => UpdateScale();
        UpdateScale();
    }

    private void UpdateScale()
    {            
        double xscale = (App.Current.MainWindow.ActualWidth) / 300;
        double yscale = (App.Current.MainWindow.ActualHeight) / 200;

        Scale = Math.Min(xscale, yscale);                       
    }
}

发布后,“消失的文字”只能在某些缩放级别上看到。它在 Debug 中运行良好。

【问题讨论】:

    标签: c# .net wpf xbap


    【解决方案1】:

    这似乎是 IE9.0 测试版中的一个错误。回滚到 IE8.0 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2010-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多