Reputation: 63
i try to bind the Itemsource Property of an Listview to my Singelton StaticEntryList.Instance ... How can i make this work with UWP (x:static is not available there)
thanks :)
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()
{
}
//...
}
}
and here the MainPage.xaml
<ListView Name="StaticEntryListView" Grid.Column="0" ItemTemplate="{StaticResource StaticEntryTemplate}" ItemsSource="{x:Bind ??? :("> </ListView>
Upvotes: 2
Views: 906
Reputation: 3746
You just need to start the binding path with the class namespace:
<ListView Name="StaticEntryListView"
Grid.Column="0"
ItemTemplate="{StaticResource StaticEntryTemplate}"
ItemsSource="{x:Bind seproject:EntryList.Instance" />
Where seproject
is the namespace tag declared in the Page
/UserControl
root element:
<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">
This is working only if targeting (at least) Windows Anniversary update (build 14393) SDK
Upvotes: 2