Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绑定和x:Bind,一个正在工作_C#_Binding_Uwp_Xbind - Fatal编程技术网

C# 绑定和x:Bind,一个正在工作

C# 绑定和x:Bind,一个正在工作,c#,binding,uwp,xbind,C#,Binding,Uwp,Xbind,我正在用绑定和x:Bind做一些测试,我发现了一些有趣的事情 XAML <ListView Background="White" ItemsSource="{x:Bind ViewModel.CurrenciesViewModel.Currencies.Currencies}"> <ListView.ItemTemplate> <DataTemplate x:DataType="model:Currency"&

我正在用绑定和x:Bind做一些测试,我发现了一些有趣的事情

XAML

<ListView Background="White" ItemsSource="{x:Bind ViewModel.CurrenciesViewModel.Currencies.Currencies}">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="model:Currency">
                    <StackPanel>
                        <TextBlock Foreground="Red" Text="1"/>
                        <TextBlock Foreground="Red" Text="{x:Bind Name}"/>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
</ListView>
但是当我用一种方法通过我的数据提供者(xml的简单rest)下载我的模型时

Task<CurrencyList> GetCurrencyList();
那么我的listView是空的!我检查了我的数据是否已下载,是的,它是。。。 我改变了x:Bind和Binding,一切正常


我可以复制粘贴所有类,如果你想的话。但是请告诉我wtf;)

问题在于{x:Bind}与{binding}中的默认绑定如何工作。在{x:Bind}中,默认绑定是一次性的,但在{binding}中,默认绑定是单向的。因此,即使在更新viewmodel时,默认情况下,数据在x:binding中也不会更改

To Resolve Change 
<TextBlock Foreground="Red" Text="{x:Bind Name}"/>
To:
<TextBlock Foreground="Red" Text="{x:Bind Name Mode=OneWay} "/>
以解决更改
致:

问题在于{x:Bind}与{binding}中的默认绑定如何工作。在{x:Bind}中,默认绑定是一次性的,但在{binding}中,默认绑定是单向的。因此,即使在更新viewmodel时,默认情况下,数据在x:binding中也不会更改

To Resolve Change 
<TextBlock Foreground="Red" Text="{x:Bind Name}"/>
To:
<TextBlock Foreground="Red" Text="{x:Bind Name Mode=OneWay} "/>
以解决更改
致:

问题在于{x:Bind}与{binding}中的默认绑定如何工作。在{x:Bind}中,默认绑定是一次性的,但在{binding}中,默认绑定是单向的。因此,即使在更新viewmodel时,默认情况下,数据在x:binding中也不会更改

To Resolve Change 
<TextBlock Foreground="Red" Text="{x:Bind Name}"/>
To:
<TextBlock Foreground="Red" Text="{x:Bind Name Mode=OneWay} "/>
以解决更改
致:

问题在于{x:Bind}与{binding}中的默认绑定如何工作。在{x:Bind}中,默认绑定是一次性的,但在{binding}中,默认绑定是单向的。因此,即使在更新viewmodel时,默认情况下,数据在x:binding中也不会更改

To Resolve Change 
<TextBlock Foreground="Red" Text="{x:Bind Name}"/>
To:
<TextBlock Foreground="Red" Text="{x:Bind Name Mode=OneWay} "/>
以解决更改
致:

我的第一个假设是绑定被破坏,因为您正在创建一个新的CurrencyListViewModel。但是,由于它使用的是绑定,而不是x:Bind,我的第二个猜测是,您在x:Bind上缺少Mode=one?默认值为OneTime。@igrali:我认为绑定中缺少相同的:
Mode=OneWay
。我的第一个假设是绑定被破坏,因为您正在创建新的CurrencyListViewModel。但是,由于它使用的是绑定,而不是x:Bind,我的第二个猜测是,您在x:Bind上缺少Mode=one?默认值为OneTime。@igrali:我认为绑定中缺少相同的:
Mode=OneWay
。我的第一个假设是绑定被破坏,因为您正在创建新的CurrencyListViewModel。但是,由于它使用的是绑定,而不是x:Bind,我的第二个猜测是,您在x:Bind上缺少Mode=one?默认值为OneTime。@igrali:我认为绑定中缺少相同的:
Mode=OneWay
。我的第一个假设是绑定被破坏,因为您正在创建新的CurrencyListViewModel。但是,由于它使用的是绑定,而不是x:Bind,我的第二个猜测是,您在x:Bind上缺少Mode=one?默认值为OneTime。@igrali:我认为绑定中缺少相同的:
Mode=OneWay