如何在ListBox的元素上应用函数?

时间:2012-05-27 19:34:34

标签: c# wpf

我有以下XAML

<ListBox Name="feedListBox" Height="468" HorizontalAlignment="Left" Margin="20,100,0,0" VerticalAlignment="Top" Width="444" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectionChanged="feedListBox_SelectionChanged"  DataContext="{Binding Source={StaticResource MyData}}">
   <ListBox.ItemTemplate>
         <DataTemplate>
              <StackPanel VerticalAlignment="Top">
                  <TextBlock TextDecorations="Underline" FontSize="24" Name="feedTitle" TextWrapping="Wrap" Margin="12,0,0,0" HorizontalAlignment="Left" Foreground="{StaticResource PhoneAccentBrush}" Text="{Binding Title.Text, Path=Arabic , Converter={StaticResource RssTextTrimmer}}"  />
                  <TextBlock Name="feedSummary" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Summary.Text, Converter={StaticResource RssTextTrimmer}}"  />
                  <TextBlock Name="feedPubDate" Foreground="{StaticResource PhoneSubtleBrush}" Margin="12,0,0,10" Text="{Binding PublishDate.DateTime}"  />
              </StackPanel>
         </DataTemplate>
   </ListBox.ItemTemplate>
</ListBox>

现在我有了这个对象

crAr = new Arabic.Controls.ArabicShape();

我想在XAML的每个元素上应用DisplayArabic方法,如下所示:

///// FeedTitle TextBlock
{TextBlock ELEMENT content} = crAr.DisplayArabic( {TextBlock ELEMENT content} );

///// FeedSummary TextBlock
{TextBlock ELEMENT content} = crAr.DisplayArabic( {TextBlock ELEMENT content} );

///// FeedPubDate TextBlock
{TextBlock ELEMENT content} = crAr.DisplayArabic( {TextBlock ELEMENT content} );

怎么能用C#编写?

1 个答案:

答案 0 :(得分:0)

试试这个How to: Bind to a Method