2017-05-12 4 views
-1

Bitte kann jemand helfen. Unten ist mein XAML-Code, der nichtXAML-Code wird nicht kompiliert

<Window x:Class="XAMLCalendar.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:local="clr-namespace:XAMLCalendar" 
     mc:Ignorable="d" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <StackPanel Orientation = "Horizontal"> 

      <!-- Create a Calendar that displays dates through 
      Januarary 31, 2015 and has dates that are not selectable. --> 

      <Calendar Margin = "20" SelectionMode = "MultipleRange" 
      IsTodayHighlighted = "false" 
      DisplayDate = "1/1/2015" 
      DisplayDateEnd = "1/31/2015" 
      SelectedDatesChanged = "Calendar_SelectedDatesChanged" 
      xmlns:sys = "clr-namespace:System;assembly =mscorlib"> 

       <Calendar.BlackoutDates> 
        <CalendarDateRange Start = "1/2/2015" End = "1/4/2015"/> 
        <CalendarDateRange Start = "1/9/2015" End = "1/9/2015"/> 
        <CalendarDateRange Start = "1/16/2015" End = "1/16/2015"/> 
        <CalendarDateRange Start = "1/23/2015" End = "1/25/2015"/> 
        <CalendarDateRange Start = "1/30/2015" End = "1/30/2015"/> 
       </Calendar.BlackoutDates> 

       <Calendar.SelectedDates> 
        <sys:DateTime>1/5/2015</sys:DateTime> 
        <sys:DateTime>1/12/2015</sys:DateTime> 
        <sys:DateTime>1/14/2015</sys:DateTime> 
        <sys:DateTime>1/13/2015</sys:DateTime> 
        <sys:DateTime>1/15/2015</sys:DateTime> 
        <sys:DateTime>1/27/2015</sys:DateTime> 
        <sys:DateTime>4/2/2015</sys:DateTime> 
       </Calendar.SelectedDates> 

      </Calendar> 
     </StackPanel> 
    </Grid> 
</Window> 

Im Folgenden wird die C# partielle Klasse hinter

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 

namespace XAMLCalendar 
{ 
    /// <summary> 
    /// Interaction logic for MainWindow.xaml 
    /// </summary> 
    public partial class MainWindow : Window 
    { 
     public MainWindow() 
     { 
      InitializeComponent(); 
     } 

     private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) 
     { 
      var calendar = sender as Calendar; 

      // ... See if a date is selected. 

      if (calendar.SelectedDate.HasValue) 
      { 
       // ... Display SelectedDate in Title. 
       DateTime date = calendar.SelectedDate.Value; 
       this.Title = date.ToShortDateString(); 
      } 
     } 
    } 
} 

unten Nachrichten I

Dateizeile

Severity-Code Beschreibung Projekt erhalten wird der Fehler kompiliert Suppression State Fehler Unbekannter Buildfehler, '' clr-namespace: System; assembly = mscorlib 'Mapping-URI ist nicht gültig. Linie 6 Position 9. ' XAMLCalendar C: \ Benutzer \ mypc \ Dokumente \ Visual Studio 2017 \ Projects \ XAMLCalendar \ XAMLCalendar \ MainWindow.xaml Linie 6

Severity Code Beschreibung Projektdatei Zeilenunterdrückungszustand Fehler Der URI „clr-namespace: System; Montage = mscorlib "ist kein gültiger Namespace-Bezeichner. XAMLCalendar C: \ Benutzer \ mypc \ Dokumente \ Visual Studio 2017 \ Projects \ XAMLCalendar \ XAMLCalendar \ MainWindow.xaml Linie 20

Severity Code Beschreibung Projektdatei Zeilenunterdrückungszustand Fehler Der Name "Datetime" existiert nicht im Namensraum "clr-namespace: System; assembly = mscorlib". XAMLCalendar C: \ Benutzer \ mypc \ Dokumente \ Visual Studio 2017 \ Projects \ XAMLCalendar \ XAMLCalendar \ MainWindow.xaml Linie 31

Severity Code Beschreibung Projektdatei Zeilenunterdrückungszustand Fehler Der Name "Datetime" existiert nicht im Namensraum "clr-namespace: System; assembly = mscorlib". XAMLCalendar C: \ Users \ mypc \ Dokumente \ Visual Studio 2017 \ Projects \ XAMLCalendar \ XAMLCalendar \ MainWindow.xaml Linie 32

........ und die gleichen Fehler wie die direkt oben, nach oben zu Zeile 37

Bitte kann mir jemand sagen, warum es nicht kompilieren wird. Ich habe versucht, mscorlib Verweis auf mein Projekt hinzufügen, aber es wird mich nicht lassen. Sprich: "Diese Komponente wird vom Buildsystem bereits automatisch referenziert"

Auch gibt es eine Wiggle-Zeile unter xmlns: sys im Calender-Element im obigen XAML. Als ich darüber meine Maus bewegen, sagt der Intellisense „Der URI‚clr-namespace: System, Montag = mscorlib‘ist kein gültiger Namensraumbezeichner

Prost ist mit Microsoft Visual Studio 2017 Community

+0

@Nikhil Agrawal Prost – Evan

Antwort

3

einfach entfernen. das zusätzliche Leerzeichen in Namespace-Deklaration.

<Window x:Class="XAMLCalendar.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:XAMLCalendar" 
    mc:Ignorable="d" 
    Title="MainWindow" Height="350" Width="525"> 
<Grid> 
    <StackPanel Orientation = "Horizontal"> 

     <!-- Create a Calendar that displays dates through 
     Januarary 31, 2015 and has dates that are not selectable. --> 

     <Calendar Margin = "20" SelectionMode = "MultipleRange" 
     IsTodayHighlighted = "false" 
     DisplayDate = "1/1/2015" 
     DisplayDateEnd = "1/31/2015" 
     SelectedDatesChanged = "Calendar_SelectedDatesChanged" 
     xmlns:sys = "clr-namespace:System;assembly=mscorlib"> 

      <Calendar.BlackoutDates> 
       <CalendarDateRange Start = "1/2/2015" End = "1/4/2015"/> 
       <CalendarDateRange Start = "1/9/2015" End = "1/9/2015"/> 
       <CalendarDateRange Start = "1/16/2015" End = "1/16/2015"/> 
       <CalendarDateRange Start = "1/23/2015" End = "1/25/2015"/> 
       <CalendarDateRange Start = "1/30/2015" End = "1/30/2015"/> 
      </Calendar.BlackoutDates> 

      <Calendar.SelectedDates> 
       <sys:DateTime>1/5/2015</sys:DateTime> 
       <sys:DateTime>1/12/2015</sys:DateTime> 
       <sys:DateTime>1/14/2015</sys:DateTime> 
       <sys:DateTime>1/13/2015</sys:DateTime> 
       <sys:DateTime>1/15/2015</sys:DateTime> 
       <sys:DateTime>1/27/2015</sys:DateTime> 
       <sys:DateTime>4/2/2015</sys:DateTime> 
      </Calendar.SelectedDates> 

     </Calendar> 
    </StackPanel> 
</Grid> 
</Window> 
+0

paaren Um dies deutlich zu machen es einen Raum war vor = mscorlib – apc

+0

@apc, Thank you! ich habe aus Versehen den Kommentar über dem Code entfernt. – Yevgeniy

+0

@apc Prost Mate. Sortiert. Sollte Assembly sein =. Sollte nicht sein zwischen der Montage und dem Gleichheitszeichen – Evan

Verwandte Themen