Frage

I've just started using Silverlight 3.0 and am wondering if this isn't available in 3.0. It seems despite all the examples I've come across, I can't seem to set styles.

The code below gives me the following error: The tag 'Type' does not exist in XML namespace | And it underlines the TargetType attribute in the Style element. Any help would be appreciated.

<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>
War es hilfreich?

Lösung

Change TargetType="{x:Type Button}" to TargetType="Button"

Silverlight 3 does not support the WPF TargetType syntax you are using.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top