C# ';14';对于属性';风格';
在下面的xaml中,我在主窗口xaml中创建了一个错误(“14”对于属性“Style”的值无效)。我仍然可以运行该应用程序,奇怪的是,该样式在运行时被正确地可视化了C# ';14';对于属性';风格';,c#,wpf,xaml,C#,Wpf,Xaml,在下面的xaml中,我在主窗口xaml中创建了一个错误(“14”对于属性“Style”的值无效)。我仍然可以运行该应用程序,奇怪的是,该样式在运行时被正确地可视化了 <UserControl x:Class="PerfectCode.TVShowManager.UserInterface.Views.TVShowControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<UserControl x:Class="PerfectCode.TVShowManager.UserInterface.Views.TVShowControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:userControls="clr-namespace:PerfectCode.TVShowManager.UserInterface.UserControls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<GroupBox>
<GroupBox.Header>
HERE I AM NOT ALLOWED TO SET THE STYLE ON MY TEXTBLOCK
<TextBlock Style="{StaticResource LargeText}" Text="{Binding Name}"/>
</GroupBox.Header>
<TabControl ItemsSource="{Binding Seasons}" SelectedItem="{Binding SelectedSeason}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Style="{StaticResource SmallText}" Text="{Binding Name}"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<userControls:SeasonControl/>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</GroupBox>
</UserControl>
这里不允许我在文本块上设置样式
无论如何,如果执行此操作,我的MainViewWindow.xaml中将出现错误
<Window x:Class="PerfectCode.TVShowManager.UserInterface.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:PerfectCode.TVShowManager.UserInterface.Views"
mc:Ignorable="d"
Title="Manage your TV Shows"
Width="1500" Height="900">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<views:ActionBar Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"/>
<views:TVShowListControl Grid.Row="1" Grid.Column="0"/>
<GridSplitter Grid.Row="1" Grid.Column="1" Width="5" HorizontalAlignment="Stretch"/>
THE NEXT LINE HAS THE ERROR
<views:TVShowControl Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" DataContext="{Binding SelectedTVShow}"/>
</Grid> </Window>
下一行有错误
注释中要求的样式:
<Style x:Key="SmallText" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="18"/>
</Style>
<Style x:Key="LargeText" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="26"/>
</Style>
正如我之前所说,一切都很好。应用程序已正确显示。groupbox的标题具有“LargeText”的所有属性,并以白色前景色显示
当我从textblock中删除样式时,然后,并且只有这样错误才会消失(重建后)
我使用的是VS2015和.NET4.6(如果与此有关,则使用R#9.2)
我在XAML中是否做了一些不正确的事情 LarGetText和SmallText有什么值?请发布你的LarGetText样式定义好吗?@SaphuA和Il-Vic,更新的问题我无法重现这个问题它有效吗fine@DeshDeepSingh您是否也在使用VS2015和.NET 4.6?(顺便说一句,谢谢你的帮助!)