ઝડપી અને સરળ: કોઈ Windows દુકાન એપ્લિકેશનમાં # સી મદદથી લંબચોરસ ખસેડો

મારી સમગ્ર બ્લોગ ફિલસૂફી તે જૂના બ્લોગ પર સંપૂર્ણપણે દંડ કે છે, અન્યત્ર મૃત્યુ આવરી લેવામાં આવ્યા છે વિષયો સ્થાયી થયા હતા.  હું આ વિષય તે એક છે ધારે, પરંતુ હું તેને કોઈપણ રીતે બ્લોગિંગ છું.

હું એક વિન્ડો દુકાન એપ્લિકેશન પર કામ કરી રહ્યો છું અને હું અમુક ઉત્સાહિત કરતું કરવાની જરૂર જ્યાં ભાગ પર છું.  આ માટે, I’ve been figuring out bits and pieces of windows store app animation which, as it turns out, is quite close to, but not exactly like, XAML based animations in .NET (I’m still coming to grips with the fact that WinRT <> .NET 🙂 ).

This morning I wanted to get a handle on drag and drop operations.  En route to that, I got bogged down moving a rectangle instead :).  Here’s the code that moves a rectangle when the user clicks a button:

   1:   
   2:              MatrixTransform ct = (MatrixTransform)rectBig.RenderTransform;
   3:              Matrix m = ct.Matrix;
   4:              m.OffsetX  = 10;
   5:              m.OffsetY  = 10;
   6:              ct.Matrix = m;
   7:              rectBig.RenderTransform = ct;

The trick here is that I can’t directly change OffsetX or OffsetY.  There may be a more clever way of doing this (and if you know and feel like, please post in the comments). 

In order to do this, I need to:

1. Get the MatrixTransform of the rectangle (by casting RenderTransform).

2. Get the Matrix of that guy.

3. Change the Matrix’s offsets.

4. Reassign the Matrix back to the MatrixTransform.

5. Reassign the MatrixTransform back to the Rectangle.

To test it, I put a rectangle and button the screen. When I click the button, the above logic executes and moves the rectangle immediately.

અમુક બિંદુએ, I’d like to animate this but I have no idea how to get a DoubleAnimation to work on it (Storyboard.SetTargetProperty() is a mystery to me on this for the time being).

</અંત>

undefinedમારા બ્લોગ પર સબ્સ્ક્રાઇબ કરો.

Twitter પર મને ખાતે અનુસરો http://www.twitter.com/pagalvin

જવાબ છોડો

તમારું ઇમેઇલ સરનામું પ્રકાશિત કરવામાં આવશે નહીં. જરૂરી ક્ષેત્રો ચિહ્નિત થયેલ છે *