简体   繁体   中英

WPF: Multibind and Inline Collections

I have the following binding in my 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>

I get an runtime error (System.Windows.Markup.XamlParseException) saying that Multibindings are not supported by Inline Collections. I need, however, Property1 and Property2 in my converter. I found a similar question but I was not able to match it to my use case.

Any ideas?

A Hyperlink can only contain Inline elements, eg a Run:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM