文本块作为Windows Phone 8中的曲线

时间:2013-10-01 18:43:33

标签: c# windows-phone-8 expression-blend

我想创建一个弯曲的文本块。它有点类似于: http://i.stack.imgur.com/sCJuQ.gif Textblock curved 我怎么能在表达混合中做到这一点? 即使我尝试在路径列表框布局上设置文本块,它也会以垂直方式而不是路径布局打印。

<FrameworkElement.Resources>
            <TextBlock x:Key="TextRes" Text="world wide web"/>
</FrameworkElement.Resources>
<mec:PathListBox  ItemsSource="{Binding Text, Source={StaticResource TextRes}}">
            <mec:PathListBox.LayoutPaths>
                <mec:LayoutPath Orientation="OrientToPath">
                    <mec:LayoutPath.SourceElement>
                        <Ellipse Height="436" Width="352" />
                    </mec:LayoutPath.SourceElement>
                </mec:LayoutPath>
            </mec:PathListBox.LayoutPaths>
 </mec:PathListBox>

1 个答案:

答案 0 :(得分:0)

试用PathListBox。关键是将ItemsSource设置为字符串并使用OrientToPath。以下xaml适用于WP7。

<mec:PathListBox xmlns:mec="clr-namespace:Microsoft.Expression.Controls;assembly=Microsoft.Expression.Controls"
  ItemsSource="world wide web">
  <mec:PathListBox.LayoutPaths>
    <mec:LayoutPath Orientation="OrientToPath">
      <mec:LayoutPath.SourceElement>
        <Ellipse Height="91" Width="300"/>
      </mec:LayoutPath.SourceElement>
    </mec:LayoutPath>
  </mec:PathListBox.LayoutPaths>
</mec:PathListBox>

即使设计师警告字符串,它也会编译并运行。或者你可以这样做:

<FrameworkElement.Resources>
  <TextBlock x:Key="TextRes" Text="world wide web"/>
</FrameworkElement.Resources>
<mec:PathListBox
  ItemsSource="{Binding Text, Source={StaticResource TextRes}}">
  <mec:PathListBox.LayoutPaths>
    <mec:LayoutPath Orientation="OrientToPath">
      <mec:LayoutPath.SourceElement>
        <Ellipse Height="91" Width="300"/>
      </mec:LayoutPath.SourceElement>
    </mec:LayoutPath>
  </mec:PathListBox.LayoutPaths>
</mec:PathListBox>