【发布时间】:2017-10-06 15:03:15
【问题描述】:
public sealed partial class MainPage : Page
{
//public static dynamic resource;
public ResourceModel vm = new ResourceModel();
public MainPage()
{
this.InitializeComponent();
}
}
public class ResourceModel
{
private Dictionary<string, string> _resource;
public Dictionary<string, string> Resource
{
get { return _resource; }
set
{
_resource=Value;
}
}
}
Xaml 代码
<TextBlock Text="{Binding vm.Resource[Account] ,Mode=TwoWay}" FontSize="15" Margin="10 0 30 0" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" Grid.Row="1" Grid.Column="0"></TextBlock>
说明 我想从没有 DataContext 和文本块名称的 ResourceModel 绑定我的文本块。只有我需要使用属性名称进行绑定。
【问题讨论】:
-
使用 x:Bind?
Text="{x:Bind vm.Resource[Account] ,Mode=TwoWay}". -
@mm8 Error Invalid binding path 'vm.Resource[Account]' 无效索引
-
@mm8 如何传递字符串“Account”