如图,在我学习利用xmlns实现在主窗口里引用另一个叫LoginView的xaml窗口时,预览可以看到引用,但是启动时却只是空白是怎么回事啊?
MainWindow.xaml:
你得定义用户控件,你是不是直接拿窗口改的?这样不行
可以借鉴下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WPFStudy
{
public class StringToHumanTypeConverter:TypeConverter
{
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if(value is string)
{
StringToHuman stringToHuman = new StringToHuman();
stringToHuman.Name = value as string;
return stringToHuman;
}
return base.ConvertFrom(context, culture, value);
}
}
}`
https://blog.csdn.net/qq_21419015/article/details/127371474
窗体没办法这么引用吧?你可以在按钮点击事件中将LoginView显示出来。
LoginView login = new LoginView();
login.Show();
可以参考 scdn 连接地址:https://blog.csdn.net/qq_21419015/article/details/127371474