【问题标题】:UserControl in XAML with parameters (Win Store App)带有参数的 XAML 中的 UserControl(Win Store 应用程序)
【发布时间】:2013-09-30 02:29:57
【问题描述】:

我需要将参数发送到我的用户控件。我现在如何实现发送,但我不知道如何获取这个参数。

我的代码:

<UserControls:ItemTemplateControl Parameter="23"/>

提前致谢!

【问题讨论】:

    标签: c# xaml windows-store-apps


    【解决方案1】:

    转到UserControl 的代码隐藏,并使用属性:

    public class ItemTemplateControl : UserControl
    {
         int _parameter;
         public int Parameter
         {
             get
             {
                 return _parameter;
             }
             set
             {
                 // do something with the given value
                 _parameter = value; // set _parameter to the given value
             }
          }
    
          // your other UserControl code here
    }
    

    更多关于 C# 属性:Properties (C# Programming Guide)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      相关资源
      最近更新 更多