Bind Singleton в XAML (UWP) - PullRequest
       8

Bind Singleton в XAML (UWP)

0 голосов
/ 04 мая 2018

я пытаюсь привязать свойство Itemsource Listview к моему Singelton StaticEntryList.Instance ... Как я могу заставить это работать с UWP (x: static там недоступен)

спасибо:)

namespace SE_Projekt
{
    public class StaticEntryList:List<Entry> {

        private static StaticEntryList _Instance;
        public static StaticEntryList Instance
        {
            get
            {
                if (_Instance == null) {
                    _Instance = new EntryList();
                }
                return _Instance;
            }
        }

        private StaticEntryList()
        {

        }
        //...
    }
}

и здесь MainPage.xaml

<ListView Name="StaticEntryListView" Grid.Column="0" ItemTemplate="{StaticResource StaticEntryTemplate}" ItemsSource="{x:Bind ??? :("> </ListView>

1 Ответ

0 голосов
/ 04 мая 2018

Вам просто нужно запустить путь привязки с пространством имен класса:

<ListView Name="StaticEntryListView" 
Grid.Column="0" 
ItemTemplate="{StaticResource StaticEntryTemplate}" 
ItemsSource="{x:Bind seproject:EntryList.Instance" />

Где seproject - тег пространства имен, объявленный в корневом элементе Page / UserControl:

<Page
  x:Class="StaticBindign.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:seproject="using:SE_Projekt"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d">

Это работает, только если нацелено (как минимум) обновление Windows Anniversary (сборка 14393) SDK

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...