为什么点击按钮不翻译容器?
Why clicked button is not translating the container?
我正在尝试使用按钮来翻译容器。对于容器上升然后下降的某些原因,当第三次单击按钮时没有任何 hapens.This 循环重复,因此每三次单击都不会按预期运行。
在 class 的顶部我声明了这个
double windowHeight;
double historyContainerHideTranslation;
double historyContainerShowTranslation;
在构造函数中我有
windowHeight = DeviceDisplay.MainDisplayInfo.Height;
historyContainerHideTranslation = windowHeight * .07;
historyContainerShowTranslation = windowHeight * -.11;
HistoryContainer.TranslationY = historyContainerHideTranslation;
以及方法...
void HistoryBtnHandler(object sender, EventArgs e)
{
Console.WriteLine(" before if height => " + HistoryContainer.TranslationY);
if (HistoryContainer.TranslationY == historyContainerHideTranslation)
{
HistoryContainer.TranslateTo(0, historyContainerShowTranslation, 250, Easing.SinOut);
HistoryContainer.TranslationY = historyContainerShowTranslation;
Console.WriteLine("if stmnt height +> " + HistoryContainer.TranslationY);
}
else
{
HistoryContainer.TranslateTo(0, historyContainerHideTranslation, 250, Easing.SinIn);
HistoryContainer.TranslationY = historyContainerHideTranslation;
Console.WriteLine("else stmnt height +> " + HistoryContainer.TranslationY);
}
Console.WriteLine("after stmts height +> " + HistoryContainer.TranslationY);
}
比较关系型数字时,使用 Math.Round() 对每个数字进行四舍五入,以指定小数点后的位数。在这种情况下,当数字四舍五入到一位数时,它们将是相同的。
我正在尝试使用按钮来翻译容器。对于容器上升然后下降的某些原因,当第三次单击按钮时没有任何 hapens.This 循环重复,因此每三次单击都不会按预期运行。
在 class 的顶部我声明了这个
double windowHeight;
double historyContainerHideTranslation;
double historyContainerShowTranslation;
在构造函数中我有
windowHeight = DeviceDisplay.MainDisplayInfo.Height;
historyContainerHideTranslation = windowHeight * .07;
historyContainerShowTranslation = windowHeight * -.11;
HistoryContainer.TranslationY = historyContainerHideTranslation;
以及方法...
void HistoryBtnHandler(object sender, EventArgs e)
{
Console.WriteLine(" before if height => " + HistoryContainer.TranslationY);
if (HistoryContainer.TranslationY == historyContainerHideTranslation)
{
HistoryContainer.TranslateTo(0, historyContainerShowTranslation, 250, Easing.SinOut);
HistoryContainer.TranslationY = historyContainerShowTranslation;
Console.WriteLine("if stmnt height +> " + HistoryContainer.TranslationY);
}
else
{
HistoryContainer.TranslateTo(0, historyContainerHideTranslation, 250, Easing.SinIn);
HistoryContainer.TranslationY = historyContainerHideTranslation;
Console.WriteLine("else stmnt height +> " + HistoryContainer.TranslationY);
}
Console.WriteLine("after stmts height +> " + HistoryContainer.TranslationY);
}
比较关系型数字时,使用 Math.Round() 对每个数字进行四舍五入,以指定小数点后的位数。在这种情况下,当数字四舍五入到一位数时,它们将是相同的。