Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 今天如何展示';使用xaml在WPF中的DatePicker控件的页脚处设置日期?_C#_Wpf_Xaml - Fatal编程技术网

C# 今天如何展示';使用xaml在WPF中的DatePicker控件的页脚处设置日期?

C# 今天如何展示';使用xaml在WPF中的DatePicker控件的页脚处设置日期?,c#,wpf,xaml,C#,Wpf,Xaml,我目前正在使用MVVM架构风格开发WPF应用程序。 当使用DatePicker控件时,面临如何在DatePicker的页脚显示今天的日期的问题。 请提供我帮助。 谢谢试试这个: <StackPanel> <DatePicker Width="100" Height="10" HorizontalAlignment="Left"/> <Label Content="{Binding Source={x:Static sys:DateTime.Now}

我目前正在使用MVVM架构风格开发WPF应用程序。 当使用DatePicker控件时,面临如何在DatePicker的页脚显示今天的日期的问题。 请提供我帮助。 谢谢

试试这个:

<StackPanel>
    <DatePicker Width="100" Height="10"  HorizontalAlignment="Left"/>
    <Label Content="{Binding Source={x:Static sys:DateTime.Now}}" />
</StackPanel>
您可以在
自定义控件中使用上述代码,也可以在需要时直接使用。

尝试以下操作:

<StackPanel>
    <DatePicker Width="100" Height="10"  HorizontalAlignment="Left"/>
    <Label Content="{Binding Source={x:Static sys:DateTime.Now}}" />
</StackPanel>

您可以在
CustomControl
中使用上述代码,也可以在需要时直接使用。

请务必注意您的问题,但让我们尝试提供帮助

首先,我假设您使用System.Windows.Controls中的DatePicker,但它应该适用于任何其他组件

如果您确实希望在日期选择器下显示当前日期,您可以执行以下XAML操作:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <DatePicker  SelectedDate="{Binding SelectedDate, Mode=OneWayToSource}" Grid.Row="0"/>
    <TextBlock Text="{Binding CurrentDate}" Grid.Row="1"/>
</Grid>
当然,您可以根据需要在日期上使用一些格式,如下所述:

但我认为更好的解决方案是将当前日期显示为默认选择,这将导致这个简单的xaml:

<DatePicker  SelectedDate="{Binding SelectedDate}"/>

希望有帮助。

请注意您的问题,但让我们尝试帮助您

首先,我假设您使用System.Windows.Controls中的DatePicker,但它应该适用于任何其他组件

如果您确实希望在日期选择器下显示当前日期,您可以执行以下XAML操作:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <DatePicker  SelectedDate="{Binding SelectedDate, Mode=OneWayToSource}" Grid.Row="0"/>
    <TextBlock Text="{Binding CurrentDate}" Grid.Row="1"/>
</Grid>
当然,您可以根据需要在日期上使用一些格式,如下所述:

但我认为更好的解决方案是将当前日期显示为默认选择,这将导致这个简单的xaml:

<DatePicker  SelectedDate="{Binding SelectedDate}"/>

希望能有所帮助。

如果我没说错,WPF没有本机DateTimePicker?您是否尝试过DateTimePicker属性
FooterVisibility
?FooterVisibility不可用。您正在使用哪个控件?WPF中没有本机DateTimePicker。您使用的是
控件吗?如果我没有错,WPF没有本机DateTimePicker?您是否尝试过DateTimePicker属性
FooterVisibility
?FooterVisibility不可用。您使用的是哪个控件?WPF中没有本机DateTimePicker。是否使用
控件?