![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Expose parameters for my user control in top level XAML Layout ? Suppose I have a usercontrol "myButton" I want someone to be able to use this control it in their XAML layout with <some container> <local:myButton param1="value1" param2="value2" /> </some container> I want param1 etc to hold a values (integer, string or Brush) that will be used in the layout of the control in the XAML but also available to the usercontrol code behind. How do I go about setting up these parameters in the "myButton" definition ? Simply having a property (or a dependency property) in the XAML/c# code for the control doesn't seem to make these parameters accessible. -- Griff (Learning to make industrial UI with XAML/WPF/c#) |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Expose parameters for my user control in top level XAML Layout? Griff wrote: > Suppose I have a usercontrol "myButton" > > I want someone to be able to use this control it in their XAML layout with > > <some container> > <local:myButton param1="value1" param2="value2" /> > </some container> > > I want param1 etc to hold a values (integer, string or Brush) that will be > used in the layout of the control in the XAML but also available to the > usercontrol code behind. > > How do I go about setting up these parameters in the "myButton" definition ? > Simply having a property (or a dependency property) in the XAML/c# code for > the control doesn't seem to make these parameters accessible. > Griff, Perhaps you need to add CLR wrappers around the property? I've seen that recommended in most custom control development documentation that I've seen (which is scant!). For example: public class CustomControl : UserControl { // Dependency Property public static readonly DependencyProperty Param1Property = DependencyProperty.Register("test", typeof(int), typeof(CustomControl), etc... // CLR wrapper for DP public int Param1 { get { return (int) GetValue (Param1Property); } set { SetValue (Param1Property, value); } } } Jason |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Expose parameters for my user control in top level XAML Layout ? Yes, you need static set and get methods for any attached property as Jason recommends. Thanks, Rob Relyea WPF Program Manager http://longhornblogs.com/rrelyea "Jason Dolinger" <jdolinger@lab49.com> wrote in message news:%23x8HiUkBGHA.2704@TK2MSFTNGP15.phx.gbl... > Griff wrote: >> Suppose I have a usercontrol "myButton" >> >> I want someone to be able to use this control it in their XAML layout >> with <some container> >> <local:myButton param1="value1" param2="value2" /> >> </some container> >> >> I want param1 etc to hold a values (integer, string or Brush) that will >> be used in the layout of the control in the XAML but also available to >> the usercontrol code behind. >> >> How do I go about setting up these parameters in the "myButton" >> definition ? >> Simply having a property (or a dependency property) in the XAML/c# code >> for the control doesn't seem to make these parameters accessible. >> > > Griff, > > Perhaps you need to add CLR wrappers around the property? I've seen that > recommended in most custom control development documentation that I've > seen (which is scant!). > > For example: > > public class CustomControl : UserControl > { > > // Dependency Property > public static readonly DependencyProperty Param1Property = > DependencyProperty.Register("test", typeof(int), typeof(CustomControl), > etc... > > > // CLR wrapper for DP > public int Param1 > { > get { return (int) GetValue (Param1Property); } > set { SetValue (Param1Property, value); } > } > > } > > > Jason |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| User Account Control (UAC) - Elevate Privilege Level | Tutorials | |||
| folder level layout | Vista file management | |||