【问题标题】:bind UriMapper.Uri to a static resource in silverlight 4将 UriMapper.Uri 绑定到 silverlight 4 中的静态资源
【发布时间】:2011-04-20 10:21:05
【问题描述】:

是否可以将下面代码中的 uri 绑定到静态资源?我在资源文件中定义了 url,并希望绑定到该文件,而不是在此处对值进行硬编码。

<navcore:UriMapper x:Key="uriMapper" >
            <navcore:UriMapping Uri="Home" MappedUri="/Home.xaml" />
</navcore:UriMapper>

我尝试像下面的示例那样声明一个静态资源并绑定到它,但它失败了

<Application.Resources>

        <local:URLContainer x:Key="URLContainer" />

        <navcore:UriMapper x:Key="uriMapper" >
            <navcore:UriMapping Uri="Home" MappedUri="{Binding Source={StaticResource URLContainer}, Path=HomeUrl}" />
        </navcore:UriMapper>

</Application.Resources>

启用 CLR 异常时出现的错误是:

对象类型 'System.Windows.Data.Binding' 不能 转换为“System.Uri”类型。

我已将资源文件构造函数设为公开,并将访问级别也设置为公开。

【问题讨论】:

    标签: silverlight silverlight-4.0 binding uri


    【解决方案1】:

    MappedUri不是Dependency Property,因此无法通过DataBinding设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多