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
我在這裏錯過了什麼?