I registered a SizeChangedHandler on my ScatterViewItem:
private void MethodBoxScatterSizeChanged(object sender, SizeChangedEventArgs args)
{
if (args.NewSize.Width < 150 && args.NewSize.Height < 150)
{
ScatterViewItem svi = sender as ScatterViewItem;
TextBox txt = new TextBox();
txt.Text = "Test";
txt.Tag = svi.Content;
svi.Content = txt;
args.Handled = true;
}
else if (args.PreviousSize.Width < 150 && args.PreviousSize.Height < 150 && args.NewSize.Height > 150 && args.NewSize.Width > 150)
{
ScatterViewItem svi = sender as ScatterViewItem;
FrameworkElement old = (svi.Content as FrameworkElement).Tag as FrameworkElement;
svi.Content = old;
args.Handled = true;
}
}
As you can see, I want to set Test as the content of the ScatterViewItem if it is small, and the original content if it is bigger again. But once I decreased it, it always stays the Test way. What am I doing wrong?