wpf - How to hide/enable UserControl in all xaml pages? -
i have user control. usercontrol have functionalities. have called usercontrol in common resource directory file. inherit resource directory page in pages. enables user control in pages. want is, want usercontrol particular page can set. code.
resource directory file:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:l="clr-namespace:usercontrols"> <!-- navigation appbar --> <l:navigationappbarusercontrol grid.row="1" grid.column="0" width="100" horizontalalignment="left" visibility="visible" /> </resourcedictionary>
window1.xaml:
<src:windowbase x:class="" xmlns:src="clr-namespace:projectone" title="window1"> <grid> //some functions... </grid> </src:windowbase>
this enable user control. page, want hide user conrol. without removing (src:windowbase).. how can hide usercontrol here? appriciated. in advance..
in windowbase class create property of type visibility , bind visisbility of usercontrol it.
windowbase
public class windowbase : window { public windowbase(visibility ucvisibility) { ucvisibility = ucvisibility; } public windowbase() : this(visibility.visible) { } public visibility ucvisibility { get; set; } //other stuff }
uc binding
<l:navigationappbarusercontrol grid.row="1" grid.column="0" width="100" horizontalalignment="left" visibility="{binding ucvisibility, relativesource={relativesource mode=findancestor, ancestortype={x:type window}}}" />
now not want show send visibility.collapsed in base constructor.
public partial class window3 : windowbase { public window3():base(visibility.collapsed) { initializecomponent(); } }
i hope help.
Comments
Post a Comment