3
おはようございます、 シルバーライトでこのクールパン効果を作り出す方法に関する情報を見つけるのが難しいです。誰も私を助けることができますか? これは私が必要とする効果を持つフラッシュサイトへのリンクです。 http://www.marcecko.com/#/銀色のパン効果
おはようございます、 シルバーライトでこのクールパン効果を作り出す方法に関する情報を見つけるのが難しいです。誰も私を助けることができますか? これは私が必要とする効果を持つフラッシュサイトへのリンクです。 http://www.marcecko.com/#/銀色のパン効果
私は本当にあまりにも効果が気に入ったので、私は行動を使用してそれを再作成:
public class PanBehavior : Behavior<ScrollViewer>
{
protected override void OnAttached()
{
this.AssociatedObject.MouseMove += new MouseEventHandler(AssociatedObject_MouseMove);
this.AssociatedObject.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
this.AssociatedObject.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
void AssociatedObject_MouseMove(object sender, MouseEventArgs e)
{
var mousePos = e.GetPosition(this.AssociatedObject);
double panningY = this.AssociatedObject.ExtentHeight - this.AssociatedObject.ViewportHeight;
double panningX = this.AssociatedObject.ExtentWidth - this.AssociatedObject.ViewportWidth;
double relativeMouseY = mousePos.Y/this.AssociatedObject.ActualHeight;
double relativeMouseX = mousePos.X/this.AssociatedObject.ActualWidth;
panningY *= relativeMouseY;
panningX *= relativeMouseX;
this.AssociatedObject.ScrollToVerticalOffset(panningY);
this.AssociatedObject.ScrollToHorizontalOffset(panningX);
}
}
ただのScrollViewerのにこの動作を追加し、それは単に動作します。例として、このxaml:
<Grid>
<ScrollViewer>
<i:Interaction.Behaviors>
<local:PanBehavior />
</i:Interaction.Behaviors>
<UniformGrid Width="1000" Height="1000" Rows="10" Columns="10">
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
<Button Content="Hello" />
</UniformGrid>
</ScrollViewer>
</Grid>
私はこれをWPFでのみテストしましたが、Silverlightでもほとんど同じように動作するはずです。 - EDIT - 両方の技術でそれをテストしました。
+1クールな質問! :)
答えに感謝します。だから、パンクラスは別のファイルに入っていますか、それともメインページファイルに置くことができますか?@ Elad Katz – user758024
どこでも好きな場所に置くことができます。 –
最後の質問が1つあります。私は接頭辞 "local"に問題があります。どのようにxmlコードで宣言する必要がありますか?@Elad Katz – user758024