本文介绍了在WPF中访问Control.Parent.Parent属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

大家好吧



i是WPF的新手,



i在Winforms中有一个项目使用了以下代码更改托管控件的父级父级的可见性:



Hi everyone

i am new to WPF,

i had a project in Winforms that used the following code to change the visibility of the parent's parent of a hosted control :

Label1.parent.parent.visible=true



如何在WPF中做同样的事情?



(标签托管在StackPanel内部感谢所有人

更多信息:

在运行时填充父包装邮件通过stackpanels ..一个数据库表中的每个员工,每个员工由stackpanel内的两个标签表示,一个用于头像,另一个用于名称



当其中一个单击标签,其他堆栈面板代表其他员工隐藏,并显示该员工输入凭据的密码框

a来自winforms项目的更大代码示例:


how can i do the same thing in WPF ?

(the label is hosted inside a StackPanel which in turn is hosted in a wrapPanel

thanks everyone
more info :
the parent wrappanel is populated at run time by stackpanels .. one for each employee in a database table,each employee is represented by two labels inside the stackpanel one for avatar and other for name

when one of the labels is clicked the other stackpanels representing other employees are hidden and a password box appears for that employee to enter credentials
a larger code sample from the winforms project :

Sub labelclick(ByVal sender As Object, ByVal e As EventArgs)
      If txtPassword.Visible Then Exit Sub
      reverseVisibility()
      For Each c As Control In pnl.Controls
          c.Visible = False
      Next
      With CType(sender, Control)
          .Parent.Visible = True
          pass = ds.Employees.FindByEmployeeID(.Tag).PassWord
          EID = .Tag
      End With
      If pass = "" Then
          With ds.Employees.FindByEmployeeID(EID)
              My.Settings.EmployeeID = .EmployeeID
              My.Settings.EmployeeName = .EmployeeName
              My.Settings.Privilage = .PrivilageType
          End With

          frmBase.Show()
          Me.Close()
      End If
      txtPassword.Focus()
  End Sub

推荐答案



这篇关于在WPF中访问Control.Parent.Parent属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:11