1. 程式人生 > >[CodeSmith] WPF依賴屬性腳本

[CodeSmith] WPF依賴屬性腳本

text bject setvalue classname csharp gist fault smi arp

<%-- 
       Name: WPF 依賴屬性
      Author: Dxq
Description: 生成WPF的依賴屬性
--%>
<%@ Template Language="C#" TargetLanguage="Text" %>

<%@ Property Name="PropertyName" Default="PropertyName" Type="System.String" Description="屬性名稱"%>
<%@ Property Name="PropertyType" Default="object"       Type="System.String" Description="屬性類型"%>
<%@ Property Name="ClassName"    Default="ClassName"    Type="System.String" Description="類的名稱"%>

/// <summary>
/// 依賴屬性 TODO:添加註釋
/// </summary>
public static readonly DependencyProperty <% = PropertyName %>Property = DependencyProperty.Register("<% = PropertyName %>", typeof(<% = PropertyType %>), typeof(<% = ClassName %>),null);
/// <summary>
/// 依賴屬性 TODO:添加註釋
/// </summary>
public <% = PropertyType %> <% = PropertyName %>
{
    get{
            return (<% = PropertyType %>)GetValue(<% = PropertyName %>Property);
       }
       
    set{
            SetValue(<% = PropertyName %>Property,value);
       }
}

[CodeSmith] WPF依賴屬性腳本