c# - WPF: Control Visibility from Database / Prerender Hook -
We have an odd need: Visibility of any control in our WPF-application is operated by the database table.
This means that we have a table that stores the name of the element and its visibility.
Now I am looking for a great way to implement this feature on the client side.
I can create my own UserControl and get it from everywhere, provides an initialized component template method. But what if someone programmed more hair control?
I do not want to know about my control at all about this mechanism. I want to hook / block in a certain point (pre-control-rendering) and I want to adjust the visibility of control according to the database.
Is this possible? And if not, how do you design it?
So what I have done here:
I inherited user typing and Event for the load event, put the check in the driver.
Then I get my controls from my custom control, it works very well.
FindName () Implementation Framework not found for any reason which I do not know, although their names are defined in xaml, here I regularly use children to find their names :
Public Static Search FindVisualChildByName & lt; T & gt; (Dependent object parent, string name) where T: DependencyObject {for (int i = 0; I & lt; visual treehelper.getChildrenCount (parent); i ++) {var kids = VisualTreeHelper.GetChild (parent, i) ; String controlName = child.GetValue (Control.NameProperty) as string; If (controlName == name) {return as baby T; } Other {T results = searchWebblogname & lt; T & gt; (Child, name); If (result! = Null) {return result; }}} Return tap; }
I do not like this solution but it works.
Comments
Post a Comment