0
我已经在内容控件中编写了一个带有Int依赖属性的内容控件。TemplateBinding + SIlverlight 4 +默认样式
控件具有包含控件模板的默认样式。
现在我面临的问题是,无论是依赖属性的值是什么,什么时候渲染它总是显示我一个零
这里的示例代码段:
<ControlTemplate x:Key="ControlTemplate2" TargetType="My:Control">
<Grid x:Name="grid" Width ="128" Height="128>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" Grid.Row="1">
<TextBlock x:Name="tbxTileCount" DataContext="{TemplateBinding TileCount}"
Text="{Binding}" Margin="10,0,0,0"
Foreground="White" VerticalAlignment="Center" FontSize="48" FontFamily="Segoe WP">
<TextBlock.RenderTransform>
<CompositeTransform/>
</TextBlock.RenderTransform>
</TextBlock>
</StackPanel>
</Grid></Grid></ControlTemplate>
/// <summary>
/// Count to be displayed
/// </summary>
public int Count
{
get { return (int)GetValue(CountProperty); }
set { SetValue(CountProperty, value); }
}
public static readonly DependencyProperty CountProperty =
DependencyProperty.Register("Count",
typeof(int),
typeof(Control),
null);
尽管dep endency属性设置为默认值,文本块的DataContext设置为0
我在这里错过了什么?