大家早上好
访问WPF c#的扩展器项中嵌入的文本框值时遇到一些麻烦。
我尝试使用filtertext.value访问文本框,但是还是无法实现。如果文本框值已更改,我想设置Filtertext。通过更改filtertext,数据网格将进行实时数据过滤。 我必须获取扩展器对象才能访问文本框对象吗?
谢谢
<Expander x:Name="canexpander" Grid.Column="1" IsHitTestVisible="True" VerticalAlignment="Top" Margin="60 -3 0 0" ToolTip="Filter">
<Border IsHitTestVisible="True" BorderThickness="1" Margin="-90 0 0 0" >
<StackPanel Margin="0 4 0 0">
<!--FILTER TEXTBOX-->
<TextBox x:Name="filtertext" Text="{Binding FilterText, Mode=TwoWay}"
ToolTip="Filterwort eingeben" Width="100" Height="18" FontSize="9"
BorderThickness="1" />
</StackPanel>
</Border>
</Expander>
MainWindow.xaml.cs
public string FilterText
{
get
{
if (_filtertext == null)
{
_filtertext = "";
return this._filtertext;
}
else
{
return this._filtertext;
}
}
set
{
if (value.ToString() == null)
{
_filtertext = "NN";
}
else
{
this._filtertext = value.ToString();
OnPropertyChanged("FilterText");
}
}
}
public void filtertext_TextChanged(object sender, RoutedEventArgs e)
{
var filtertext = FindName("filtertext");
}