如何将字符串值从资源文件传递给ConverterParameter?

时间:2017-12-18 15:10:26

标签: c# xamarin mvvm xamarin.forms ivalueconverter

我想传递这个资源,在代码中看起来像这样:

AppResources.lbCountry;

这里为ConverterParameter

<Label Text="{Binding SelectedCountry.Name, Converter={StaticResource nullToResourceConv}, ConverterParameter={--}}"  >

修改

lbCountry中的

AppResources

internal static string lbCountry {
            get {
                return ResourceManager.GetString("lbCountry", resourceCulture);
            }
        }

Resx命名空间定义:

xmlns:Resx="clr-namespace:XamApp.Resources"  

但这不起作用:

ConverterParameter={x:Static Resx:AppResources.lbCountry}}

错误:

  

x:静态:无法找到公共静态字段,静态属性,   在Resx:AppResources

中命名为lbCountry的const或enum值

1 个答案:

答案 0 :(得分:0)

试试这个:

Sub ipsearch()
    Dim IE As New InternetExplorer, html As HTMLDocument
    Dim post As Object

    With IE
        .Visible = False
        .navigate "https://whatismyipaddress.com/ip/2.99.247.66"
        Do Until .readyState = READYSTATE_COMPLETE: Loop
        Set html = .document
    End With

    For Each post In html.getElementsByTagName("th")
        If InStr(post.innerText, "Country:") > 0 Then [A1] = post.ParentNode.LastChild.innerText: Exit For
    Next post
    IE.Quit
End Sub

同时确保该属性为1. Microsoft Internet Controls 2. Microsoft HTML Object Library