60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using HeBianGu.Base.WpfBase;
|
|
using HeBianGu.Control.Explorer;
|
|
using HeBianGu.Service.Mvc;
|
|
using HeBianGu.Window.Link;
|
|
using Hopetry.Provider.Behaviors;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Threading;
|
|
|
|
namespace HeBianGu.App.Disk.Send
|
|
{
|
|
/// <summary>
|
|
/// HomeControl.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class SendControl : UserControl
|
|
{
|
|
public SendControl()
|
|
{
|
|
InitializeComponent();
|
|
this.Loaded += OnLoaded;
|
|
}
|
|
private async void OnLoaded(object sender, RoutedEventArgs e)
|
|
{
|
|
// 查找h:Explorer控件
|
|
var box = FindVisualChild<ListBox>(this);
|
|
var fream= FindVisualChild<LinkActionFrame>(this);
|
|
|
|
if (box != null &&fream!=null && this.DataContext is SendViewModel viewModel)
|
|
{
|
|
IActionResult result = await viewModel.SelectLink.GetActionResult();
|
|
var uielement = result.View as UIElement;
|
|
fream.Content = uielement;
|
|
}
|
|
}
|
|
|
|
// 辅助方法:在可视化树中查找指定类型的子元素
|
|
private static T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
|
|
{
|
|
if (parent == null) return null;
|
|
|
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
|
{
|
|
var child = VisualTreeHelper.GetChild(parent, i);
|
|
if (child is T result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
var childResult = FindVisualChild<T>(child);
|
|
if (childResult != null)
|
|
{
|
|
return childResult;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|