0
,和我不会使TextChanged事件提供UM使用用户控制器TextChanged事件时不可使用我创建了一个搜索用户控制器的用户控制
<UserControl x:Class="VSOft.WpfControls.VSeachTextBox.VSearchTextBox"
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"
xmlns:local="clr-namespace:VSOft.WpfControls.VSeachTextBox"
xmlns:resx="clr-namespace:VSOft.WpfControls.Properties"
xmlns:VFontAwsome="clr-namespace:VSOft.WpfControls.VFontAwsome"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Height="25" MouseLeftButtonDown="UserControl_MouseLeftButtonDown">
<Viewbox>
<Grid>
<TextBox
x:Name="SearchText"
Margin="0"
TextWrapping="Wrap"
Text="" Height="25"
GotFocus="SearchText_GotFocus"
TextInput="SearchText_TextInput"
TextChanged="SearchText_TextChanged" />
<Label x:Name="SearchHelperLabel" Content="Search" Height="25" Foreground="#FF9E9292" GotFocus="SearchHelperLabel_GotFocus" />
<TextBlock x:Name="SearchTextIcon" TextWrapping="Wrap" Margin="275,0,0,0" Height="25" Foreground="{x:Null}" GotFocus="SearchTextIcon_GotFocus" HorizontalAlignment="Right">
<VFontAwsome:VFontAwsome VForeground="{DynamicResource SideBar.Icon.Normal}" VFontSize="20" VFontsType="search" Height="25" Width="25" HorizontalAlignment="Right" />
</TextBlock>
</Grid>
</Viewbox>
时,这是我的实现。如何在使用用户控件时使Textchanged Event可用?要做到这一点
是你的事件没有被解雇或你想从mainwindow调用它? – Rohit
嗨凯尔它触发我想从mainwindow调用它。谢谢 – Kalanamith
你想在mainwindow中为你的函数添加不同的实现,还是使用现有的实现?如果你想使用现有的,那么你可以通过创建它的对象并访问它的属性来直接调用usercontrol事件,比如'myUsercontrol.SearchText_GotFocus(this,null)' – Rohit