[英]WPF Clear UserControl's children
I'm creating a UserControl in WPF, and the UserControl works so that when the user moves mouse over the control, it's childcontrols should be removed, but I don't seem to find the Children property or anything like that.. 我在WPF中创建一个UserControl,UserControl工作,当用户将鼠标移到控件上时,应该删除它的子控件,但我似乎没有找到Children属性或类似的东西..
XAML is here: XAML在这里:
<UserControl x:Class="myTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Name="thisTextBox"
mc:Ignorable="d" d:DesignWidth="300" Height="57" MouseEnter="UserControl_MouseEnter_1" MouseLeave="UserControl_MouseLeave_1">
<TextBlock Name="TypeText" TextWrapping="NoWrap" Text="" />
</UserControl>
And in code I need to do something like this to get the TextBlock go away: 在代码中我需要做这样的事情来让TextBlock消失:
private void UserControl_MouseEnter_1(object sender, MouseEventArgs e)
{
Children.Clear(); // There is no such thing as children here!!!
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.