在App.xaml上添加BasedOn Style正在崩溃App(){InitializeCompone
将项目调整为
Template10,我在App.xaml中继承了继承的样式.
它看起来像Template10,不支持继承或扩展样式.我试图从TitleStyle扩展SubTitleStyle但我在XamlTypeInfo.g.cs中的GetXamlType上获得了COM异常 我的App.xaml.cs sealed partial class App : BootStrapper { public App() { InitializeComponent(); } public override async Task OnStartAsync(StartKind startKind,IActivatedEventArgs args) { NavigationService.Navigate(typeof(ShellView)) await Task.CompletedTask; } } 我的App.xaml <Style x:Key="TitleStyle" TargetType="TextBlock"> <Setter Property="Foreground" Value="{StaticResource TextTitleForeground}"/> <Setter Property="FontSize" Value="26"/> <Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="FontWeight" Value="Medium"/> </Style> <Style x:Key="SubTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource TitleStyle}"> <Setter Property="Foreground" Value="{StaticResource TextForeground}"/> <Setter Property="FontSize" Value="20"/> </Style> 例外信息: Error HRESULT E_FAIL has been returned from a call to a COM component. at System.Runtime.InteropServices.WindowsRuntime.IIterator`1.MoveNext() at System.Runtime.InteropServices.WindowsRuntime.IteratorToEnumeratorAdapter`1.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at Template10.Common.BootStrapper.<InitializeFrameAsync>d__77.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Template10.Common.BootStrapper.<InternalLaunchAsync>d__53.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state) at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore() 解决方法
这让我非常困惑.我很容易重现这一点.然后,我很容易在不引用模板10的情况下重现这一点.违规代码是T10中的这个块:
// title foreach (var resource in Application.Current.Resources .Where(x => x.Key.Equals(typeof(Controls.CustomTitleBar)))) { var control = new Controls.CustomTitleBar(); control.Style = resource.Value as Style; } 你可以简化它: var a = Application.Current.Resources.ToArray(); 放置在OnLaunched的任何应用程序的应用程序中.繁荣.当我们尝试访问资源集合时,错误本身就会出现,但只有在向资源添加了BasedOn样式时才会出现. 在与平台团队坐下来尝试维护模板10之后,桌子周围的每个人都开始摸不着头脑.而且,当我意识到@dachibox时,你在XAML平台上发现了一个真正的错误. 这是我们更新模板10之前唯一的当前解决方法. <Page.Resources> <ResourceDictionary Source="..StylesCustom.xaml" /> </Page.Resources> 我的意思是,你在页面而不是在App中完成工作.那么,如果不修复XAML平台,我们将如何修复模板10?看看我们将在Bootstrapper中使用的这个令人难以置信的代码: int count = Application.Current.Resources.Count; foreach (var resource in Application.Current.Resources) { var k = resource.Key; if (k == typeof(Controls.CustomTitleBar)) { var s = resource.Value as Style; var t = new Controls.CustomTitleBar(); t.Style = s; } count--; if (count == 0) break; } 错误,至少是在迭代器的count属性中,当你迭代它时,它似乎递增而不是递减.疯了吧?事实证明,这个迭代路径不是常见的用例.但是,现在没关系,我们在这里提出了问题. 我将在本周的某个时候更新模板10. 祝你好运,杰里 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-7 – 从Visual Studio 2012中删除窗口阴影/光晕
- 如何在Windows中为diskpart cmd创建批处理文件,可以锁定(只
- windows-server-2008-r2 – 用户在终端服务器上看到Windows
- windows-server-2008 – NAT上的域控制器
- windows-8 – 如何通过CLI或AHK在Windows 8中打开“设备和打
- Windows上的路由信息??是否有C/C++ API?
- windows-server-2003 – Windows文件共享上每个文件夹的最大
- 批处理文件 – cmd / DOS批处理脚本中变量周围的方括号表示
- windows – 从vim会话中删除缓冲区
- 疑难杂症----Windows10
- 如何在Windows 7中安装和配置mysql 5.6.16
- 如何在Windows 8 XAML中激活控件的高度
- Windows Socket 最大连接数
- windows-server-2016 – S2D警告:找不到用于缓存
- winforms – 获取System.Windows.Forms.RichText
- Windows 7触摸屏Java Swing =延迟的鼠标事件
- windows-7 – 使用GlusterFS和Windows避免SPOFS
- .net – 分析进程中加载??的本机DLL和程序集的内
- windows – 我在哪里(安全地)获取libintl3.dll?
- Windows 8 C#/ XAML – 在文本框文本周围创建一个