c# - WPF SurfaceButton that drops down SurfaceScrollViewer on click -
as title says, i'd have component base surfacebutton, , when clicked drop down surfacescrollviewer. think i've made proper first steps, surfacescrollviewer never becomes visible, nor seem show in blend's hierarchy. accessing or initializing incorrectly? have multiple instances of surfacedropdown objects children of stackpanel, content of surfacescrollviewer. parenting scroll viewer aligned in grid, why set heights , widths using actualheight/width properties.
public class surfacedropdown : surfacebutton { public surfacescrollviewer scrollviewer; private stackpanel stackpanel; public surfacedropdown() { this.click += onclick; scrollviewer = new surfacescrollviewer(); scrollviewer.height = this.actualheight * 5.0; scrollviewer.width = this.actualwidth; scrollviewer.horizontalalignment = system.windows.horizontalalignment.center; scrollviewer.verticalalignment = system.windows.verticalalignment.center; scrollviewer.horizontalscrollbarvisibility = scrollbarvisibility.disabled; scrollviewer.verticalscrollbarvisibility = scrollbarvisibility.auto; stackpanel = new stackpanel(); (int = 0; < 5; ++i) { label label = new label(); label.content = "label " + i.tostring(); stackpanel.children.add(label); } scrollviewer.content = stackpanel; scrollviewer.scrollchanged += onscroll; this.addchild(scrollviewer); } private void onclick(object sender, routedeventargs e) { scrollviewer.visibility = scrollviewer.visibility != visibility.visible ? visibility.visible : visibility.collapsed; } private void onscroll(object sender, routedeventargs e) { } }
any and/or suggestions appreciated!
Comments
Post a Comment