我正在尝试创建一个由 // Using 16ms because 60Hz is already good for human eyes.
private readonly DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(16) };
public ScrollingTextBlock()
{
this.InitializeComponent();
timer.Tick += (sender, e) =>
{
// Calculate the total offset to scroll. It is fixed after your text is set.
// Since we need to scroll to the "start" of the text,
// the offset is equal the length of your text plus the length of the space,
// which is the difference of the ActualWidth of the two TextBlocks.
double offset = ScrollTextBlock.ActualWidth - NormalTextBlock.ActualWidth;
// Scroll it horizontally.
// Notice the Math.Min here. You cannot scroll more than offset.
// " + 2" is just the distance it advances,
// meaning that it also controls the speed of the animation.
RealScrollViewer.ChangeView(Math.Min(RealScrollViewer.HorizontalOffset + 2, offset), null, null);
// If scroll to the offset
if (RealScrollViewer.HorizontalOffset == offset)
{
// Re-display the NormalTextBlock first so that the text won't blink because they overlap.
NormalTextBlock.Visibility = Visibility.Visible;
// Hide the ScrollTextBlock.
// Hiding it will also set the HorizontalOffset of RealScrollViewer to 0,
// so that RealScrollViewer will be scrolling from the beginning of ScrollTextBlock next time.
ScrollTextBlock.Visibility = Visibility.Collapsed;
// Stop the animation/ticking.
timer.Stop();
}
};
}
public void StartScrolling()
{
// Checking timer.IsEnabled is to avoid restarting the animation when the text is already scrolling.
// IsEnabled is true if timer has started, false if timer is stopped.
// Checking TextScrollViewer.ScrollableWidth is for making sure the text is scrollable.
if (timer.IsEnabled || TextScrollViewer.ScrollableWidth == 0) return;
// Display this first so that user won't feel NormalTextBlock will be hidden.
ScrollTextBlock.Visibility = Visibility.Visible;
// Hide the NormalTextBlock so that it won't overlap with ScrollTextBlock when scrolling.
NormalTextBlock.Visibility = Visibility.Collapsed;
// Start the animation/ticking.
timer.Start();
}
组成的组件,该组件将包含为月的选项,其值是其数字日期(例如:Jan = 1,Feb = 2,等等),以及日期和年份由常规数字输入控制。所有这些都将返回日期格式,例如““ 9/26/2019”
到目前为止,我可以选择月份并返回诸如 builder
.ForSqlServerHasIndex(x => x.ColumnX)
.ForSqlServerInclude(nameof(TableA.ColumnA), nameof(TableA.ColumnB))
.HasFilter($"{nameof(TableA.ColumnX)} = 1 AND {nameof(TableA.IsDeleted)} = 0")
.HasName($"IX_{nameof(TableA)}_{nameof(TableA.ColumnX)}_Filter_1}");
builder
.ForSqlServerHasIndex(x => x.ColumnX)
.ForSqlServerInclude(nameof(TableA.ColumnA), nameof(TableA.ColumnB))
.HasFilter($"{nameof(TableA.ColumnX)} = 0 AND {nameof(TableA.IsDeleted)} = 0")
.HasName($"IX_{nameof(TableA)}_{nameof(TableA.ColumnX)}_Filter_0}");
之类的信息,但是我不确定如何处理日期和年份。
我也正在使用名为luxon的库来使用<select>
来获取当前日期,希望将默认值传递给这些输入,但是我也不确定如何实现这一目标。
到目前为止,这就是我所拥有的:
https://codesandbox.io/s/gallant-shaw-qpc9r
我的问题是:是否有一种方法可以一次完全处理所有这些问题并输出"12"
之类的格式?还是我应该坚持使用3个完全不同的输入来控制每个字段?还是有一种方法可以利用Luxon返回所需的日期格式?