내 usercontrol에서 ViewUser
groupbox 헤더 및 textblock은 UserID를 표시하지 않습니까?usercontrol의 공개 문자열에 아무 것도 표시되지 않습니까?
메인 창 :
private void btnGeneral_Click(object sender, RoutedEventArgs e)
{
ViewUser myusercontrol = new ViewUser();
String id = (String)((Button)sender).Tag;
myusercontrol.UserID = id;
PanelMainContent.Children.Add(myusercontrol);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string uriUsers = "http://localhost:8000/Service/User";
XDocument xDoc = XDocument.Load(uriUsers);
var sortedXdoc = xDoc.Descendants("User")
.OrderByDescending(x => Convert.ToDateTime(x.Element("TimeAdded").Value));
foreach (var node in xDoc.Descendants("User"))
{
Button btnFindStudent = new Button();
btnUser.Click += this.btnGeneral_Click;
btnUser.Tag = String.Format(node.Element("UserID").Value);
//also tryed btnUser.Tag = node.Element("UserID").Value;
UserControl을 : 당신은 사용자 ID 전에 groupBox1.Header 및 textBlock1.Text을 설정하는
public partial class ViewUser : UserControl
{
public ViewUser()
{
InitializeComponent();
}
private string _user;
public string UserID
{
get { return _userID; }
set { _userID = value; }
}
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
groupBox1.Header = UserID;
textBlock1.Text = UserID;
}
}
}
base.OnPreRender (e); 존재하지 않는가? –
및 onprerender에 대한 적절한 방법이 없습니다 –
오 촬영 - WPF ASP.NET을 생각하고있었습니다. 아무리해도 컨트롤 수명주기에서 비슷한 점이있을 것입니다. set-from-property 옵션 – n8wrl