Christian Ofria
Christian Ofria

Reputation: 1

Set DataContext in a custom control

I'm trying to set the DataContext in a CustomControl, but the namespace I declared where the ViewModels are stored is not available in the code.

These are steps I've done:

IntelliSense doesn't see the 'vm' namespace and Visual Studio show me the error message than 'vm' resource is not available.

Where am I wrong? This is the code:

<UserControl x:Class="Valkin.UI.Idm.View.ArticlePricesListViewControl"
             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:vm ="clr-namespace:Valkin.UI.Idm.ViewModel"
             xmlns:uc="clr-namespace:Valkin.UI.Idm.View"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid DataContext="{StaticResource vm}">
        <ListView x:Name="tempList">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <uc:ArticlePriceListViewItemControl />
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</UserControl>

Upvotes: 0

Views: 17

Answers (0)

Related Questions