문제

I have a canvas on which i have a textBlock, and i have a hyperlink inside textBlock. i can access the canvas on my grid and Textblock on the canvas with following code, but dnt know how to access hyperlink inside textBlock, ANy idea guys ?

    canvas+textBlock+hyperlink code:


          <Canvas Grid.Column="2" ClipToBounds="True" Name="canMain" Background="Beige" Margin="12,25" Grid.RowSpan="2"   >
          <TextBlock FontSize="15" Name="tbmarquee" Canvas.Left="10" Width="169"> 
           <Hyperlink NavigateUri="http://www.google.com"  RequestNavigate="Hyperlink_RequestNavigate"  Cursor="Hand" >
                                <!--Google page link--> 
          </Hyperlink>
        </TextBlock>
        </Canvas>

and i Access the canvas and TextBlock dynamically with following code:

     IEnumerable<Canvas> cnvss = this.gride.Children.OfType<Canvas>();
                foreach (Canvas cnvs in cnvss)
                {
     IEnumerable<TextBlock> txs = cnvs.Children.OfType<TextBlock>();
                         foreach(TextBlock tbs in txs )
                        {

                        }
                }

How to access the hyperlink ?

도움이 되었습니까?

해결책

You can try to get Hyperlink from TextBlock's Inlines property, for example :

var h = tbs.Inlines.OfType<Hyperlink>().FirstOrDefault();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top