我目前正在按照步骤http://www.windowsphonegeek.com/articles/Creating-a-WP7-Custom-Control-in-7-Steps?在为WP7进行自定义控制。我创建了我的控制在一个正常的Windows手机肖像页xaml文件(结合一些控制),我不知道如何将它转换为generic.xaml文件(作为ResourceDictionary)工作。到目前为止它没有工作。WP7的自定义控件(generic.xaml)
我试图使用Expression Blend做转换,但我不知道该怎么做。
编辑:我张贴我的代码,它是一个显示动态时间的框。我还想添加用于提供日期的属性以及用于框的颜色的属性。
这是迄今为止的代码。
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
xmlns:local="clr-namespace:CereTime">
<!-- Check xmlns:local im case of error -->
<Style TargetType="local:CereT1">
<!-- After specifing the custom properties in .cs file, implement them here -->
<Setter Property="Date" Value="{TemplateBinding Date}" /> <!-- Under check -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:CereT1">
<Canvas Background="YellowGreen" Width="100" Height="100" Name="DateBox" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel Orientation="Vertical" Height="100" Width="100">
<TextBlock Name="Month" Text="Month" Foreground="White" TextAlignment="Center" HorizontalAlignment="Center" FontSize="24" FontWeight="Bold" Margin="0,12,0,0" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,6,0,0">
<TextBlock Name="Date" Text="0" VerticalAlignment="Bottom" Margin="0,0,5,0" FontSize="26.667"/>
<TextBlock Name="No_Name" Text="|" FontSize="26.667" />
<TextBlock Name="Year" Text="Year" Margin="5,0,0,0" FontSize="26.667" />
</StackPanel>
</StackPanel>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
请给我建议。 谢谢,
假设你已经完成了教程和它的工作原理(如果不是,请说明问题)究竟是你想转换为generic.xaml? –