How do I instantiate a class within a wpf? [closed]

2

The thing goes further, the problem is that it always returns this error when instantiating this class:

namespace AlmoxarifadoUpas
{
  class ConsultaMaterialEntradaSaida
  {
    private IEnumerable<MaterialA> materiais = new List<MaterialA>();

    private void adicionarMaterialAutoComplete()
    {
        using (Entities db = new Entities())
        {
            db.Configuration.ProxyCreationEnabled = false;
            var mate = from material in db.MaterialA
                       select material;
            materiais = mate.ToList();
        }
    }

    public IEnumerable<MaterialA> listaAutoComplete
    {
        get
        {
            adicionarMaterialAutoComplete();
            return materiais;
        }
    }
}
}

Error:

  

The name "SqlSourceName" does not exist in the namespace "clr-namespace:

I found it strange because this class is within the namespace. In this case I was testing with any other class, for example this class DAO (does not have the contents of the methods because I did not find it necessary, and wanted to simplify):

namespace AlmoxarifadoUpas
{
    class MaterialDAO : IMateriais
    {
        public void InserirMaterial(MaterialA material)

        public List<MaterialA> Listar()

        public bool VerificarSeCodigoExiste(string codigoMaterial)

        public void RemoverMaterial(MaterialA material)

        public void EditarMaterial(int id, string codigo, string nome, string unidade)

        public void EntradaDeMateriais(HistoricoMovimentacao historico)

        public void SaidaDeMateriais(HistoricoMovimentacao historico)

    }
}

I do not know about you, but I did not find the difference, and simply when I put this class up it does not appear the error, does anyone know what it can be? Follow below as I'm instantiating in xaml

                                                

    <DockPanel>
        <StackPanel x:Name="search" Orientation="Vertical">
            <StackPanel.Resources>
                <Style TargetType="{x:Type StackPanel}">
                    <Setter Property="Orientation" Value="Vertical" />
                    <Setter Property="Margin" Value="0,0,0,10" />
                </Style>
                <Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}">
                    <Setter Property="HorizontalAlignment" Value="Center" />
                    <Setter Property="Margin" Value="0,0,0,6" />
                </Style>
                <DataTemplate x:Key="template">
                    <Border BorderBrush="White" BorderThickness="2" CornerRadius="3">
                        <Grid Background="White">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <TextBlock Text="Código:    "/>
                            <TextBlock Grid.Column="1" Text="{Binding codigo}" />
                            <TextBlock Grid.Row="1" Text="Material:     " />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding nome}"/>
                            <TextBlock Grid.Row="2" Text="Unidade:  " />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding unidade}" />
                            <TextBlock Grid.Row="3" Text="Saldo:  " />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding saldo}" />
                        </Grid>
                    </Border>
                </DataTemplate>
                **<app:ConsultaMaterialEntradaSaida x:Key="listaMaterial" />**
            </StackPanel.Resources>

            <StackPanel>
                <Label Content="Pesquisar por nome" Target="{Binding ElementName=AutoCompleteNome}"/>
                <Grid >
                    <actb:AutoCompleteTextBox 
                            x:Name="AutoCompleteNome"
                            VerticalAlignment="Top"
                            Width="250"
                            ItemsSource="{Binding Source={StaticResource listaMaterial}, Path=listaAutoComplete}"
                            ItemTemplate="{StaticResource template}"
                            Binding="{Binding nome}" 
                            MaxCompletions="10" />
                </Grid>
            </StackPanel>
        </StackPanel>
    </DockPanel>

    <DockPanel Grid.Row="1">
        <ScrollViewer>
            <StackPanel MinWidth="400">
                <TextBlock Text="Incluir entrada de insumos" Style="{StaticResource Heading2}" Margin="0,0,0,8" />
                <StackPanel x:Name="Form" Orientation="Vertical">

                    <StackPanel.Resources>
                        <Style TargetType="{x:Type StackPanel}">
                            <Setter Property="Orientation" Value="Horizontal" />
                            <Setter Property="Margin" Value="0,0,0,10" />
                        </Style>
                        <Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}">
                            <Setter Property="Width" Value="200" />
                            <Setter Property="VerticalAlignment" Value="Center" />
                        </Style>
                    </StackPanel.Resources>
                    <!-- create viewmodel -->
                    <StackPanel.DataContext>
                        <app:MainWindow />
                    </StackPanel.DataContext>

                    <StackPanel>
                        <Label Content="Origem" Target="{Binding ElementName=TextOrigem}"/>
                        <TextBox x:Name="TextOrigem" Width="150" Text="{Binding Origem, Mode=TwoWay, ValidatesOnDataErrors=True}" />
                    </StackPanel>
                    <StackPanel>
                        <Label Content="Destino" Target="{Binding ElementName=TextDestino}"/>
                        <TextBox x:Name="TextDestino" Width="150" Text="{Binding Destino, Mode=TwoWay, ValidatesOnDataErrors=True}"/>
                    </StackPanel>
                    <StackPanel>
                        <Label Content="Quantidade movimentada" Target="{Binding ElementName=TextMovimento}"/>
                        <TextBox x:Name="TextMovimento" Width="150"/>
                    </StackPanel>
                    <Button Content="Confirmar" Margin="200,16,0,0" HorizontalAlignment="Left" Click="Button_Click" />
                </StackPanel>
                <!-- actual form starts here -->
            </StackPanel>
        </ScrollViewer>
    </DockPanel>
</Grid>

    
asked by anonymous 10.03.2017 / 14:47

1 answer

0

    
15.03.2017 / 13:29