这个是类型问题么?
跳转事件 <ec:NavigateToPageAction TargetPage="/Face.xaml?selectedItem=2"/>
对应Name <phone:PivotItem x:Name="Face2" Header="无节操">
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (DataContext == null)
{
if (NavigationContext.QueryString.ContainsKey("selectedItem"))
{
String index ="Face"+ this.NavigationContext.QueryString["selectedItem"];
DataContext = App.ViewModel;
FaceName.SelectedItem = index as Object;
}
}
}
只要点击就抛异常,如果直接赋值 FaceName.SelectedItem = Face2; 就通过
该怎么转换类型?
------解决方案--------------------Face2是对象名,怎么能用字符串呢。
public static List<T> GetVisualChildCollection<T>(object parent) where T : UIElement
{
List<T> visualCollection = new List<T>();
GetVisualChildCollection<T>(parent as DependencyObject, visualCollection);