2011-07-29 21 views
0

現在、手順http://www.windowsphonegeek.com/articles/Creating-a-WP7-Custom-Control-in-7-Stepsに従っていますか? WP7のためのカスタムコントロールを行う際に。通常のWindows Phone PortraitPage xamlファイル(いくつかのコントロールを組み合わせたもの)でコントロールを作成しましたが、generic.xamlファイル(ResourceDictionaryとして)で動作するように変換する方法がわかりません。これまでのところうまくいきませんでした。カスタムコントロール(generic.xaml)for WP7

変換を行うためにExpression Blendを使用しようとしましたが、それを行う方法がわかりません。

編集:私は自分のコードを掲示しています、それは動的な時間を表示するボックスです。また、Dateを提供するプロパティとボックスの色を追加するプロパティも追加します。

これまでのコードです。

<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> 

親切にアドバイスしてください。あなたはResourceDictionaryのにユーザーコントロールのスタイルを移動することができますが、あなたのユーザーコントロールのために、対応するXAMLでそのテンプレートを持つことができたときに おかげで、

+0

Application.Resourcesタグに

<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="themes/generic.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> 

を追加することですgeneric.xamlに変換しますか? –

答えて

0

、なぜわざわざ?

MyUserControl.xamlの内側に、変更したい他のプロパティを設定します。

しかし、カスタムコントロールのスタイルをResourceDictionaryに分割することについては、UserControlsとはあまり関係ありません。おそらく、が本当にであることを、メタ質問をするのではなく、間違って教えてください。

+0

この(曖昧な)質問は、ユーザーコントロールではなくカスタムコントロールを指します。 –

0

私は同じ問題を抱えています。
ソリューションは、まさにあなたがしようとしているあなたはチュートリアルを終えたし、それが動作(そうでない場合は、問題を記述してください)と仮定すると、App.xaml

関連する問題