.NET Framework Developer Center > .NET Development Forums > Windows Presentation Foundation (WPF) > XAML: Markup Expression twice in same line, but is "translated" only once
Ask a questionAsk a question
 

AnswerXAML: Markup Expression twice in same line, but is "translated" only once

  • Friday, November 06, 2009 6:00 AMHerbert336 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hello,

    I am programmin a silverlight data grid. The data basis is a list of stocks, which all have a Symbol (e.g. YHOO, SAP ...) I am defining a column with a Hyperlink which will lead the user to another page of the same silverlight app (UrlRouting).
                   <data:DataGridTemplateColumn Header="Chart"><br/>
                        <data:DataGridTemplateColumn.CellTemplate><br/>
                            <DataTemplate><br/>
                                <StackPanel><br/>
                                    <HyperlinkButton NavigateUri="/ChartPage/{Binding Path=Symbol}" <br/>
                                          TargetName="ContentFrame" Content="{Binding Path=Symbol}"/><br/>
                                </StackPanel><br/>
                            </DataTemplate><br/>
                        </data:DataGridTemplateColumn.CellTemplate><br/>
                    </data:DataGridTemplateColumn>
    
    See, there is twice the Markup Expression {Binding Path=Symbol} :
    The first one provides the NavigateUrl (e.g. "/ChartPage/YHOO" )
    The second one provides the label name of the hyperlink.
    My Problem: The second expression will be translated, but not the first. So the label is written correctly ("YHOO"), but the Uri will end in "/ChartPage/{Binding Path=Symbol}", which I can see in the Browser.

    Why there will be only one Markup Expression "translated"?

    To be complete, here is the definition of the UriMapper:
    <uriMapper:UriMapper>
      <uriMapper:UriMapping Uri="" MappedUri="/Views/ScreeningTable.xaml"/>
       <uriMapper:UriMapping Uri="/ChartPage/{Symbol}" MappedUri="/Views/ChartPage.xaml?symbol={Symbol}"/>
      <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
      </uriMapper:UriMapper>
    
    The UriRouting works fine, e.g. "/About" will deliver the "/Views/About.xaml" page!

    Any hint is appreciated.
    Herbert

Answers

  • Saturday, November 07, 2009 5:04 AMHerbert336 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Found the problem :-)

    I cannot bind a string to the NavigateUri property. I need to define a converter to convert the string into a Uri object.

    Solution found here:

    http://forums.silverlight.net/forums/t/16055.aspx
    • Marked As Answer byHerbert336 Saturday, November 07, 2009 5:05 AM
    •  

All Replies

  • Saturday, November 07, 2009 5:04 AMHerbert336 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Found the problem :-)

    I cannot bind a string to the NavigateUri property. I need to define a converter to convert the string into a Uri object.

    Solution found here:

    http://forums.silverlight.net/forums/t/16055.aspx
    • Marked As Answer byHerbert336 Saturday, November 07, 2009 5:05 AM
    •  
  • Saturday, November 07, 2009 5:12 AMHerbert336 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Well, to be more detailed:

    I cannot assemble a literal with a MarkupExtension.
    Thus, I must bind the whole string, but not something like NavigateUri="/ChartPage/{Binding Path=Symbol}" . Possible would be a whole  NavigateUri="{Binding ChartUri}" .