I've defined a class name TextColumns.cs, which has a DependencyProperty RichTextBlockContentProperty:
public static readonly DependencyProperty RichTextBlockContentProperty = DependencyProperty.Register("RichTextBlockContent", typeof(string), typeof(RichTextColumns), new PropertyMetadata("")); public string RichTextBlockContent { get { return (string)GetValue(RichTextBlockContentProperty); } set //Debug, but the SetValue won't fire { SetValue(RichTextBlockContentProperty, value); } }
In the XAML, I use it as
<FlipView x:Name="flipView" ItemsSource="{Binding Source={StaticResource itemsViewSource}}"> <FlipView.ItemTemplate> <DataTemplate x:Name="myDataTemplate"> <UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates"> <ScrollViewer x:Name="scrollViewer" Style="{StaticResource HorizontalScrollViewerStyle}" Grid.Row="1"> <!-- Content is allowed to flow across as many columns as needed --> <common:RichTextColumns x:Name="richTextColumns" Margin="117,0,117,47" RichTextBlockContent="{Binding title}"> <RichTextBlock x:Name="richTextBlock" Width="560" Style="{StaticResource ItemRichTextStyle}"> <Paragraph> <Run x:Name="RunText" FontSize="26" FontWeight="SemiBold" Text="{Binding title}"/> </Paragraph> </RichTextBlock> </common:RichTextColumns></UserControl></DataTemplate></FlipView.ItemTemplate></FlipView>
When the page loaded, it's supposed that the RichTextBlockContent will get the value of the Binding "title", while the Binding in the RichTextBlock worked.
So I'm wondering if there is something I've missed?
Thx in advance.
Answer: 1
The setter won't get called. If you need to do logic when the value gets set you need to supply a PropertyChanged callback in the PropertyMetadata Constructor
by : wdavohttp://stackoverflow.com/users/807836
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog