我刚刚开始使用Silverlight 3.0,我想知道这是否在3.0中不可用。尽管我遇到了所有的例子,但我似乎无法设置样式。
下面的代码给出了以下错误:XML名称空间中不存在标记“Type” |它强调了Style元素中的TargetType属性。任何帮助将不胜感激。
<UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input" x:Class="MultiSelectFileUploader.MainPage"
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"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<UserControl.Resources>
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Width" Value="150" />
<Setter Property="Margin" Value="0 0 250 0" />
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<controls:TabControl>
<controls:TabItem Header="Upload Files">
<!--<Button x:Name="btnBrowse" Grid.Row="0" Width="150" Margin="0 0 250 0" Content="Browse" Click="btnBrowse_Click" />-->
<Button Style="{StaticResource ButtonStyle}" x:Name="btnBrowse" Grid.Row="0" Content="Browse" Click="btnBrowse_Click" />
</controls:TabItem>
<controls:TabItem Header="View Files" >
</controls:TabItem>
</controls:TabControl>
</Grid>
</UserControl>
答案 0 :(得分:1)
将TargetType="{x:Type Button}"
更改为TargetType="Button"
Silverlight 3不支持您正在使用的WPF TargetType语法。