I’m trying to do a random tile flip animation in my application from the codebehind. A timer should cause a ranodom tile to flip every 3 seconds. I’ve been searching the internet on how to perform such an animation, but I can’t seem to find anything that works.
The Views are as follows with one container view holding the two views that are supposed to be flipped with each other. One is an image, and in the other view theres two textblocks
//Create single news container
Canvas container = new Canvas
{
Height = viewHeight,
Width = viewWidth,
MaxWidth = viewWidth,
MaxHeight = viewHeight,
Margin = new Thickness(viewX, viewY, 0, 0)
};
//Create image container
Canvas imageContainer = new Canvas
{
Height = viewHeight,
Width = viewWidth,
MaxWidth = viewWidth,
MaxHeight = viewHeight,
Background = new SolidColorBrush(Colors.Transparent),
Visibility = Visibility.Collapsed
};
//Create title and leadtext container
Canvas textContainer = new Canvas
{
Height = viewHeight,
Width = viewWidth,
MaxWidth = viewWidth,
MaxHeight = viewHeight,
Background = GetCategoryColor(news.Cat[0]),
Visibility = Visibility.Visible,
};
//Set image source and crop image accordingly
var image = new BitmapImage(new Uri(news.ImageUrl[0]));
var viewImage = new Image
{
Source = image,
Height = viewHeight,
Width = viewWidth,
MaxWidth = viewWidth,
MaxHeight = viewHeight,
Stretch = Stretch.UniformToFill
};
//Set header view
TextBlock title = new TextBlock
{
MaxHeight = titleHeight,
MaxWidth = titleWidth,
Height = titleHeight,
Width = titleWidth,
Text = news.Title,
Margin = new Thickness(titleX, titleY, 0, 0),
Padding = new Thickness(framePadding),
Foreground = new SolidColorBrush(Colors.White),
TextWrapping = TextWrapping.Wrap,
FontWeight = FontWeights.Bold,
FontSize = 22,
FontFamily = new FontFamily("Calibri"),
TextTrimming = TextTrimming.WordEllipsis
};
//Set ingress view
TextBlock leadText = new TextBlock
{
MaxHeight = leadTextHeight,
MaxWidth = leadTextWidth,
Height = leadTextHeight,
Width = leadTextWidth,
Margin = new Thickness(leadTextX, leadTextY, 0, 0),
Padding = new Thickness(framePadding, 0, framePadding, framePadding),
Text = news.LeadText,
Foreground = new SolidColorBrush(Colors.White),
TextWrapping = TextWrapping.Wrap,
FontSize = 18,
FontFamily = new FontFamily("Calibri"),
TextTrimming = TextTrimming.WordEllipsis
};
//Add subviews to container and viewlist
imageContainer.Children.Add(viewImage);
textContainer.Children.Add(title);
textContainer.Children.Add(leadText);
container.Children.Add(imageContainer);
container.Children.Add(textContainer);
_viewsList.Add(container);
//Add single news container to main content canvas
ContentCanvas.Children.Add(container);
Hope somebody can help me here!
Found of course an answer to my question a couple of minutes after I created the question, and heres the answer (http://codepaste.net/xyo2ib)