로드 된 느슨한 xaml 파일에 정의 된 텍스트 상자에 텍스트를 설정하고 싶습니다. 텍스트 상자는 응용 프로그램의 일부입니다.로드 된 느슨한 xaml 파일의 컨트롤에 프로그래밍 방식으로 텍스트 설정
StackPanel LooseRoot;
if (fTeleFound == true)
{
try
{
using (System.IO.FileStream fs = new System.IO.FileStream(sXamlFileName, System.IO.FileMode.Open))
{
LooseRoot = (StackPanel)System.Windows.Markup.XamlReader.Load(fs);
}
this.DetailsViewFrame.Children.Add(LooseRoot);
}
catch (ArgumentException ex)
{
// TBD Error xamlfile
return;
}
// set Elements
//foreach (TextBox textBox in LooseRoot.Children as TextBox) // does not work ?
//{
//
//}
}
XAML 파일은 다음과 같이이다 : 세부 항목이 해당 응용 프로그램이 새 컴파일하지 않고 사용자 정의 할 수 있습니다 볼에 대한
<StackPanel Margin="10" Orientation="Vertical"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Orientation="Horizontal">
<Label Margin="5,5,0,5">CRCDB=</Label>
<TextBox Margin="0,5,5,5" Name="DetailsviewTB1" Height="20"/>
<Label Margin="10,5,0,5">Infonummer=</Label>
<TextBox Margin="0,5,5,5" Name="DetailsviewTB2" Height="20"/>
<Label Margin="10,5,0,5">Daten=</Label>
<TextBox Margin="0,5,5,5" Name="DetailsviewTB3" Height="20"/>
</StackPanel>
이입니다. 느슨한 xaml 파일의 양과 이름은 컴파일 타임에 알려지지 않습니다.
텍스트 상자의 텍스트를 동적으로 어떻게 설정할 수 있습니까? TextBox에 어떤 데이터가 들어 있는지 지정할 수있는 추가 xml-File이 있습니다.
감사합니다. 데이터 바인딩 실제로 작동했습니다. – user1550097
@ user1550097 : 도움이 되셨습니다. :) –