Wpf 我可以将DataTemplate访问到codebehind吗
我使用的是WPF,我有Wpf 我可以将DataTemplate访问到codebehind吗,wpf,Wpf,我使用的是WPF,我有DataTemplate,我想访问codebehind 我怎么能用这个 谢谢。 <Window.Resources> <DataTemplate x:Key="PersonDataTemplate"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Name}" /> <TextBlock Tex
DataTemplate
,我想访问codebehind
我怎么能用这个
谢谢。
<Window.Resources>
<DataTemplate x:Key="PersonDataTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=Age}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
public Window1()
{
InitializeComponent();
DataTemplate dataTemplate = FindResource("PersonDataTemplate") as DataTemplate;
}
公共窗口1()
{
初始化组件();
DataTemplate DataTemplate=FindResource(“PersonDataTemplate”)作为DataTemplate;
}
但如何找到DataTemplate内部的控件,即TextBlock,并在运行时从codebehind更改值?请帮忙。。。!谢谢我在找这个:D