A
A
Alexey Gerasimov2015-08-12 18:07:05
XAML
Alexey Gerasimov, 2015-08-12 18:07:05

How to display data in xaml constructor?

In VS, the xaml designer has such a feature that allows you to display some data in the designer without compiling the application, I managed to google only the old Silverlight material and it didn’t take off for me. Here's how I do it:

<UserControl.Resources>
        <x:DummyList x:Key="DummyData"/>
        <CollectionViewSource x:Name="Dummys" Source="{StaticResource DummyData}"/>
</UserControl.Resources>
...
<ListBox Grid.Row="1" ItemsSource="{Binding}" Style="{StaticResource JagermasterListbox}" d:DataContext="{Binding}">
...
namespace TargetList
{
    public sealed partial class TargetsListManage : UserControl
    {
        public class DummyList : List<TargetsListItem>
        {
            public DummyList()
            {
                AddRange(TargetsModel.DefaultTargets);
            }
        }
    }
}

But Severity
Code Description Project File Line
Error The type 'x: DummyList' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. TargetList C:\Temp\ToDoConverter451\ToUniversal\ToDoConverter451\TargetList\TargetsListManage.xaml 13
I am trying to do this in Universal App

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Gerasimov, 2015-08-12
@starostin13

Everything, I understood correctly.

public class DummyList : List<TargetsListItem>
    {
        public DummyList()
        {
            AddRange(TargetsModel.DefaultTargets);
        }
    }

- must not be a subclass

A
ar4ebaldello, 2015-08-12
@ar4ebaldello

"DummyList" is nested in "TargetsListManage" => worth using its fully qualified name == "TargetsListManage.DummyList"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question