正在将WPF xaml转换为Silverlight xaml



除了一件事之外,我几乎成功地转换了所有内容。

这是有问题的部分-

<ContentPresenter Margin="2,2,2,2" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>

这是整个xaml(不那么长)-

 <Window.Resources>
    <SolidColorBrush x:Key="OutlookButtonForeground" Color="#FF204D89"/>
    <LinearGradientBrush x:Key="OutlookButtonBackground" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFD9EDFF" Offset="0"/>
        <GradientStop Color="#FFC0DEFF" Offset="0.445"/>
        <GradientStop Color="#FFC0D9FB" Offset="1"/>
        <GradientStop Color="#FFAFD1F8" Offset="0.53"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="OutlookButtonHighlight" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFBD69" Offset="0"/>
        <GradientStop Color="#FFFFB75A" Offset="0.0967"/>
        <GradientStop Color="#FFFFB14C" Offset="0.2580"/>
        <GradientStop Color="#FFFB8C3C" Offset="0.3870"/>
        <GradientStop Color="#FFFEB461" Offset="0.9677"/>
        <GradientStop Color="#FFFEBB67" Offset="1"/>
    </LinearGradientBrush>
    <Style x:Key="OutlookTabControlStyle" TargetType="TabControl">
        <Setter Property="Foreground" Value="{StaticResource OutlookButtonForeground}"/>
        <Setter Property="Background" Value="{StaticResource OutlookButtonBackground}"/>
        <Setter Property="BorderThickness" Value="3"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="MinWidth" Value="10"/>
        <Setter Property="MinHeight" Value="10"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabControl">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                            <RowDefinition x:Name="RowDefinition1" Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid x:Name="ContentPanel" Grid.Column="0" Grid.Row="1">
                            <Border
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">
                                <ContentPresenter Margin="2,2,2,2" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>
                            </Border>
                        </Grid>
                        <StackPanel HorizontalAlignment="Stretch" Margin="0,-2,0,0"
                x:Name="HeaderPanel" VerticalAlignment="Bottom" Width="Auto" 
            Height="Auto" Grid.Row="1" IsItemsHost="True"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
    <TabControl VerticalAlignment="Stretch" Width="360" Height="Auto" TabStripPlacement="Bottom" Style="{StaticResource OutlookTabControlStyle}" BorderBrush="#FF6593CF" HorizontalAlignment="Left" BorderThickness="1,1,1,0">
        <TabItem Header="Mail" Height="30"  Background="{StaticResource OutlookButtonBackground}" Foreground="{StaticResource OutlookButtonForeground}">
            <Grid>
                <TextBlock Text="Mail"/>
            </Grid>
        </TabItem>
        <TabItem Header="Calender" Height="30"  Background="{StaticResource OutlookButtonBackground}" Foreground="{StaticResource OutlookButtonForeground}">
            <Grid>
                <TextBlock Text="Calender"/>
            </Grid>
        </TabItem>
    </TabControl>
</Grid>

ContentSource不是Silverlight中ContentPresenter控件的依赖属性。不幸的是,我不知道Silverlight中的use/equilant属性,所以我会查看msdn文档,了解如何迁移值(http://msdn.microsoft.com/en-us/library/system.windows.controls.contentpresenter(v=vs.95).aspx)

相关内容

  • 没有找到相关文章