2016-11-17 1 views
0

VS의 xaml-editor는 계속 "Invalid Markup"messg를 제공합니다. wpf의 사용자 지정 명령 바인딩

나는, 클래스 CustomCommands.cs을 추가 XAML 등 에 Windows.CommandBindings을 추가했지만 VS 출력 오류는 다음과 같습니다

[Failure] Could not find file 'c:\users\bart\documents\visual studio 2015\Projects\examentest200\examentest200\CustomCommands.cs'.

동안, 내가 탐색기에서 파일을 선택하면, 그것은이있다. 사전에

감사

"CustomCommands.cs"

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Input; 

namespace examentest200 
{ 
public static class CustomCommands 
{ 
    public static readonly RoutedUICommand Change = new RoutedUICommand 
(
      "Change", 
     "Change", 
     typeof(CustomCommands), 
     new InputGestureCollection() 
     { 
      new KeyGesture(Key.F6, ModifierKeys.Alt) 
     } 
    ); 

    } 
} 

XAML :

<Window x:Class="examentest200.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:examentest200" 

    mc:Ignorable="d" 
    Title="MainWindow" Height="350" Width="525"> 

<Window.CommandBindings> 
    <CommandBinding Command="ApplicationCommands.New" 
        Executed="NewCommand_Executed" 
        CanExecute="NewCommand_CanExecute" 


            /> 
    <CommandBinding Command="local:CustomCommands.Change" 
        Executed="ChangeCommand_Executed" 
        CanExecute="ChangeCommand_CanExecute" /> 


</Window.CommandBindings> 

<Grid> 
    <Button x:Name="addButton" Command="ApplicationCommands.New" Content="Add" HorizontalAlignment="Left" Margin="10,24,0,0" VerticalAlignment="Top" Width="75"/> 
    <ListBox x:Name="eersteListBox" DisplayMemberPath="Model" SelectedIndex="0" Background="Aquamarine" HorizontalAlignment="Left" Height="100" Margin="110,24,0,0" VerticalAlignment="Top" Width="100"/> 
    <ComboBox x:Name="eersteComboBox" DisplayMemberPath="Make" SelectedIndex="0" HorizontalAlignment="Left" Margin="239,28,0,0" VerticalAlignment="Top" Width="100"/> 
    <Label x:Name="eersteLabel" DataContext="{Binding Path=SelectedItem, ElementName=eersteListBox, Mode=OneWay}" Content="{Binding Path=Make}" Background="CornflowerBlue" HorizontalAlignment="Left" Margin="376,28,0,0" VerticalAlignment="Top" Width="102"/> 
    <Label x:Name="tweedeLabel" DataContext="{Binding Path=SelectedItem, ElementName=eersteListBox, Mode=OneWay}" Content="{Binding Path=Model}" Background="CadetBlue" HorizontalAlignment="Left" Margin="376,70,0,0" VerticalAlignment="Top" Width="102"/> 
    <Label x:Name="derdeLabel" DataContext="{Binding Path=SelectedItem, ElementName=eersteListBox, Mode=OneWay}" Content="{Binding Path=Year}" Background="Gold" HorizontalAlignment="Left" Margin="376,114,0,0" VerticalAlignment="Top" Width="102" Height="28"/> 
    <ComboBox x:Name="countryComboBox" SelectedIndex="0" DisplayMemberPath="Land" HorizontalAlignment="Left" Margin="110,187,0,0" VerticalAlignment="Top" Width="120"/> 
    <Button x:Name="delButton" Content="Del" HorizontalAlignment="Left" Margin="10,70,0,0" VerticalAlignment="Top" Width="75"/> 


    <Button x:Name="changeButton" Command="local:CustomCommands.Change" Content="Change" HorizontalAlignment="Left" Margin="10,114,0,0" VerticalAlignment="Top" Width="75"/> 



    <TextBox x:Name="eersteTextBox" Background="LightGray" HorizontalAlignment="Left" Height="23" Margin="376,187,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/> 
    <TextBox x:Name="tweedeTextBox" Background="LightBlue" HorizontalAlignment="Left" Height="23" Margin="376,220,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/> 
    <TextBox x:Name="derdeTextBox" Background="LightCyan" HorizontalAlignment="Left" Height="23" Margin="376,254,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/> 
    <TextBox x:Name="vierdeTextBox" HorizontalAlignment="Left" Height="23" Margin="376,287,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/> 

</Grid> 

+2

솔루션 탐색기에서이 파일을 볼 수 있습니까? – McNets

+0

프로젝트를 만들었습니까? XAML 디자이너는 아직 컴파일되지 않은 코드를 보지 않습니다. –

+0

감사합니다. – bart

답변

-1

이 오류가 나타나면 :

[Failure] Could not find file 'c:\users\bart\documents\visual studio 2015\Projects\examentest200\examentest200\CustomCommands.cs'.

... CustomCommands.cs은 아직 컴파일되지 않았을 가능성이 큽니다. XAML 디자이너는 프로젝트가 빌드 될 때까지 클래스를 볼 수 없습니다.

관련 문제