0

In my MVVM project, trying to bind view model to my page, I receive error message: "The tag 'DesignInstance' does not exist in XML namespace 'http://schemas.microsoft.com/expression/blend/2008'. Line 7 Position 7.". really have no idea how to fix it(

<Page x:Class="Workers_managment_entity_framework_practice.Workers_redacting_page"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:Workers_managment_entity_framework_practice.ViewModel"
      DataContext="{d:DesignInstance Type=local:WorkersViewModel}"
      mc:Ignorable="d"
      d:DesignHeight="800" d:DesignWidth="800"
      Title="Workers_redacting_page">

    <Grid Background="Black">

        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Grid.Row="1"></Grid>
        <TextBlock FontSize="40" Foreground="White">First name:</TextBlock>  
        <TextBox Text="{Binding FirstNameView}" FontSize="40" VerticalAlignment="Bottom" Margin="5"></TextBox>

        <TextBlock FontSize="40" Grid.Row="1" Foreground="White">Last name:</TextBlock>
        <TextBox Text="{Binding LastNameView}" FontSize="40" VerticalAlignment="Bottom" Margin="5" Grid.Row="1"></TextBox>

        <TextBlock FontSize="40" Grid.Row="2" Foreground="White">Salary:</TextBlock>
        <TextBox Text="{Binding SalaryView}" FontSize="40" VerticalAlignment="Bottom" Margin="5" Grid.Row="2"></TextBox>

        <TextBlock FontSize="40" Grid.Row="3" Foreground="White">Work experience:</TextBlock>
        <TextBox Text="{Binding WorkExperienceView}" FontSize="40" VerticalAlignment="Bottom" Margin="5" Grid.Row="3"></TextBox>

        <Button Command="{Binding AddWorker}" Grid.Row="4" Margin="70,30" Background="Orange" Foreground="White" FontSize="50">ADD</Button>
    </Grid>
</Page>
  • Odds are that this will not solve your problem. But just in case, try using the `x:Type` markup extension in that line #7. So rewrite it like this: `DataContext="{d:DesignInstance {x:Type local:WorkersViewModel}}"` I think that's the better way to write it instead of just writing `Type=` – Joe Oct 02 '22 at 15:48
  • You do not set the runtime DataContext to a DesignInstance, only the design-time DataContext: `d:DataContext="{d:DesignInstance local:WorkersViewModel}"` – Clemens Oct 02 '22 at 16:08

0 Answers0