2012-03-27 115 views
0

除了一件事之外,我已经成功转换了几乎所有的东西。将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> 

回答

0

ContentSource没有为Silverlight中ContentPresenter控制依赖项属性。不幸的是,我不知道Silverlight中的use/equivilant属性,因此我会查看msdn文档以了解如何迁移该值(http://msdn.microsoft.com/zh-cn/library/system。 windows.controls.contentpresenter(v = vs.95).aspx)

+0

感谢@Dave S,那么我应该在那里写什么呢? – Erez 2012-03-27 13:48:04

+0

我不确定什么是SelectedContent值被设置? - 猜测它只是看起来像内容,所以尝试使用内容DP来代替。 – 2012-03-27 13:48:56