获取userControl所在的xaml根目录

时间:2014-04-26 13:51:24

标签: c# reflection winrt-xaml

在c#(winRt)中使用Reflection,可以动态获取userControl所属页面的根目录吗?

UserControl xaml

  <SearchBox PlaceholderText="{Binding placeholder,Mode=TwoWay}" 
                   Width="300"
                   Margin="20,0,20,0"                   
                   SearchHistoryEnabled="False"
                   FocusOnKeyboardInput="False"
                   ChooseSuggestionOnEnter="True"
                   SuggestionsRequested="SearchBoxSuggestions"
                   ResultSuggestionChosen="SuggestionChoosen"
                   QueryChanged="SearchQueryChanged"
                   HorizontalAlignment="Left"
                   x:Name="searchBox"
                />

后面的UserControl代码
    public void SuggestionChoosen(Windows.UI.Xaml.Controls.SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
    {
        int p = Convert.ToInt32(args.Tag);
        TransporterExt t = new TransporterExt();
        t = suggested[p];
        selected = t;

        //I WANT TO GET HERE THE ROOT OF THE PAGE IN WHICH USER CONTROLLER BELONGS TO
    }

如何从UserControl的codeBehind获取页面的根目录?

0 个答案:

没有答案