2017-04-08 17 views
0

私はc#(UWP)を学び、XAMLで通知テキストブロックを作成しました。C#UWP - 通知パネル

ここにある:

<Storyboard x:Name="notificationPanel1"> 
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="notificationBorder"> 
     <DiscreteObjectKeyFrame KeyTime="0"> 
      <DiscreteObjectKeyFrame.Value> 
       <Thickness>0,-80,0,0</Thickness> 
      </DiscreteObjectKeyFrame.Value> 
     </DiscreteObjectKeyFrame> 
    </ObjectAnimationUsingKeyFrames> 
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="notificationBorder"> 
     <EasingDoubleKeyFrame KeyTime="0" Value="0"> 
      <EasingDoubleKeyFrame.EasingFunction> 
       <BackEase EasingMode="EaseInOut"/> 
      </EasingDoubleKeyFrame.EasingFunction> 
     </EasingDoubleKeyFrame> 
     <EasingDoubleKeyFrame KeyTime="0:0:1.5" Value="75"> 
      <EasingDoubleKeyFrame.EasingFunction> 
       <BackEase EasingMode="EaseInOut"/> 
      </EasingDoubleKeyFrame.EasingFunction> 
     </EasingDoubleKeyFrame> 
     <EasingDoubleKeyFrame KeyTime="0:0:2" Value="75"> 
      <EasingDoubleKeyFrame.EasingFunction> 
       <BackEase EasingMode="EaseInOut"/> 
      </EasingDoubleKeyFrame.EasingFunction> 
     </EasingDoubleKeyFrame> 
    </DoubleAnimationUsingKeyFrames> 
</Storyboard> 
<Grid> 
.... 
     <Border x:Name="notificationBorder" BorderBrush="{x:Null}" VerticalAlignment="Top" Margin="0,-80,0,0" RenderTransformOrigin="0.5,0.5"> 
      <Border.RenderTransform> 
       <CompositeTransform/> 
      </Border.RenderTransform> 
      <TextBlock x:Name="notificationTxt" TextWrapping="Wrap" Padding="0" TextAlignment="Center" Foreground="White" Text="sdfdsfsdf" Margin="0,15"/> 
     </Border> 
.... 
</Grid> 

はこれを行うには良い方法はありますか?これで、このXAMLをすべてのページにコピーする必要があります。

Mbはこれを動的に生成しますか?しかし、私はどのように、私にヒントを与えることができますか分からない?

ところで:これは基本的にアニメーション化されて通知パネル enter image description here

+1

は、ユーザーコントロールのそれを入れて、そしてちょうどすべてのページを渡ってそれを使用することです! –

+0

@PedroLamas、返信いただきありがとうございます。私が言ったように、私はC#を学んでいるので、今私はどのようにカスタムコントロールを作成するか分かりません。しかし、私はgoogleでそれをチェックします。ありがとう –

+2

usercontrolで始まり​​ます(これはページのようなもので、Visual Studioから直接追加できます)。あなたがまだ学んでいるように、それはカスタムコントロールよりも扱いが簡単です! –

答えて

0

は、この例を見てください、ありがとうございました。これはXamarin Apps向けですが、サンプルはUWP固有です。画面の下部に他のすべての上部に通知が表示されます。静的メソッドで呼び出すことができます。実際のサンプルアプリケーションは少し混乱するかもしれませんが、Xamarin Formsの仕組みを理解すれば、必要なものを引き出すことができます。レポはここにあります。あなたが必要なもの

https://github.com/MelbourneDeveloper/Adapt.Presentation

https://github.com/MelbourneDeveloper/Adapt.Presentation/blob/master/Adapt.Presentation.UWP/Adapt/Presentation/UWP/InAppNotification.xaml.cs

https://github.com/MelbourneDeveloper/Adapt.Presentation/blob/master/Adapt.Presentation.UWP/Adapt/Presentation/UWP/InAppNotification.xaml

関連する問題