【问题标题】:WPF: Multibind and Inline CollectionsWPF:多绑定和内联集合
【发布时间】:2021-01-31 07:33:48
【问题描述】:

我的 GridViewColumn 中有以下绑定

 <GridViewColumn Header="Text" Width="40">
     <GridViewColumn.CellTemplate>
         <DataTemplate>
            <TextBlock TextAlignment="Center">
              <Hyperlink NavigateUri="{Binding Path=Link}" RequestNavigate="Hyperlink_OnRequestNavigate">                                                                                                          
                  <MultiBinding Converter="{StaticResource LinkDisplayConverter}">    
                      <Binding Path="Property1"/> 
                      <Binding Path="Property2"/> 
                  </MultiBinding>                                                                                                        
              </Hyperlink>  
            </TextBlock>
         </DataTemplate>
  </GridViewColumn.CellTemplate>

我收到一个运行时错误 (System.Windows.Markup.XamlParseException),指出内联集合不支持多重绑定。但是,我的转换器中需要 Property1 和 Property2。我发现了一个类似的问题,但我无法将其与我的用例相匹配。

有什么想法吗?

【问题讨论】:

  • 你的转换器有什么?
  • 我更新了我的问题。事实上,我确实收到了运行时错误(异常)。我的转换器中有什么并不重要 - 我有一个简单的(见上文)并得到错误。
  • 转换器不相关。

标签: c# wpf gridview data-binding multibinding


【解决方案1】:

超链接只能包含内联元素,例如运行:

<Hyperlink NavigateUri="{Binding Link}" RequestNavigate="Hyperlink_OnRequestNavigate">                                                                                                          
    <Run>
        <Run.Text>
            <MultiBinding Converter="{StaticResource LinkDisplayConverter}">    
                <Binding Path="Property1"/> 
                <Binding Path="Property2"/> 
            </MultiBinding>                                                                                                        
        <Run.Text>
    <Run>
</Hyperlink>

【讨论】:

    猜你喜欢
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 2010-12-10
    相关资源
    最近更新 更多