简体   繁体   中英

Why can't I insert a Calendar or a date time picker in WPF?

I'm trying to insert a Calendar in WPF application by inserting calendar tags but I'm getting this error?

The type 'calendar' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built Here is the code :-

<Window x:Class="HomeExpenseCalculator.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window1" Height="395.516" Width="445.511">
    <Grid>
        <Label Height="25" Name="label1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="88" FontSize="14" Margin="14,15,0,0" Background="White">Person</Label>
        <ComboBox Height="23" Margin="159.984,15,95.546,0" Name="comboBox1" VerticalAlignment="Top">
            <ComboBoxItem>Pankaj</ComboBoxItem>
            <ComboBoxItem>Shad</ComboBoxItem>
            <ComboBoxItem>Kartik</ComboBoxItem>
            <ComboBoxItem>Abhinav</ComboBoxItem>
            <ComboBoxItem>Rahul</ComboBoxItem>
        </ComboBox>
        <Label Height="28" Margin="3,63.327,0,0" Name="label2" VerticalAlignment="Top"   HorizontalAlignment="Left" Width="99" FontSize="12" Background="White">Stuff   Purchased</Label>
        <TextBox Height="63" Margin="111,48,38,0" Name="textBox1" VerticalAlignment="Top" />
        <Calendar> </Calendar>
    </Grid>
</Window>

I created a new window and added the calender control with no errors. Here is what the XAML looked like:

<Window x:Class="StackOverflow.TestWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="TestWindow" Height="300" Width="300">
    <Grid>
        <Calendar />
    </Grid>
</Window>

Please be more detailed in your question.

This error means you don't have the correct assembly.

See: WPF assembly reference missing - project still building

Perhaps you don't have a reference to the correct namespace in the XAML? (ie xmlns=...).

You need to reference the namespace that the calendar control is in for it to work...

使用Calendar而不是'日历'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM