http://www.cnblogs.com/ManMonth/archive/2011/08/30/2159956.html
说明
using System;
using System.Net;
using System.windows;
using System.windows.Controls;
using System.windows.documents;
using System.windows.Ink;
using System.windows.input;
using System.windows.Media;
using System.windows.Media.Animation;
using System.windows.Shapes;
namespace ENPOT.distribution.Management.VIEw
{
public class UcSearchPanel : ContentControl
{
private button _btnRset;
private button _btnSearch;
static UcSearchPanel()
{
DefaultStyleKeyProperty.GetMetadata(typeof(UcSearchPanel));
}
// Methods
public UcSearchPanel()
{
base.DefaultStyleKey = typeof(UcSearchPanel);
}
public overrIDe voID OnApplyTemplate()
{
base.OnApplyTemplate();
this.btnRset = base.GetTemplateChild("btnRset") as button;
this.btnSearch = base.GetTemplateChild("btnSearch") as button;
}
private button btnRset
{
get
{
return this._btnRset;
}
set
{
if (this._btnRset != null)
{
this._btnRset.Click -= new RoutedEventHandler(this.resetbutton_Click);
}
this._btnRset = value;
if (this._btnRset != null)
{
this._btnRset.Click += new RoutedEventHandler(this.resetbutton_Click);
}
}
}
private button btnSearch
{
get
{
return this._btnSearch;
}
set
{
if (this._btnSearch != null)
{
this._btnSearch.Click -= new RoutedEventHandler(this.Searchbutton_Click);
}
this._btnSearch = value;
if (this._btnSearch != null)
{
this._btnSearch.Click += new RoutedEventHandler(this.Searchbutton_Click);
}
}
}
private voID resetbutton_Click(object sender,RoutedEventArgs e)
{
if (this.resetEventHandler != null)
{
this.resetEventHandler(sender,e);
}
}
private voID Searchbutton_Click(object sender,RoutedEventArgs e)
{
if (this.SearchEventHandler != null)
{
this.SearchEventHandler(sender,e);
}
}
public event EventHandler SearchEventHandler;
public event EventHandler resetEventHandler;
}
}
<!--搜索控件-->
<Style targettype="uc:UcSearchPanel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate targettype="uc:UcSearchPanel">
<GrID x:name="LayoutRoot">
<border GrID.Column="0" CornerRadius="2" borderBrush="#95A4B1" borderThickness="1">
<GrID>
<GrID.RowDeFinitions>
<RowDeFinition Height="30"/>
<RowDeFinition Height="*"/>
<RowDeFinition Height="60"/>
</GrID.RowDeFinitions>
<!--提示-->
<StackPanel GrID.Row="0" HorizontalAlignment="Stretch" margin="0" VerticalAlignment="Stretch"
Background="{StaticResource ModuleSelectorBackgroundBrush}"
OrIEntation="Horizontal">
<StackPanel.Effect>
<DropShadowEffect color="Gray" ShadowDepth="0" BlurRadius="2" Opacity="0.6"/>
</StackPanel.Effect>
<TextBlock Text="{StaticResource UcAuditSaleOrder_Search}" VerticalAlignment="Center" margin="5,0"/>
</StackPanel>
<ContentPresenter GrID.Row="1" VerticalAlignment="top"
HorizontalAlignment="Stretch" />
<!--按钮-->
<button x:name="btnRset" GrID.Row="2"
Style="{StaticResource Toolbutton}"
HorizontalAlignment="RIght"
VerticalAlignment="top"
margin="10,10,90,20"
>
<StackPanel OrIEntation="Horizontal" >
<Image WIDth="16"
Height="16"
Source="/ENPOT.distribution.Management;component/Resources/Images/rest.png"
margin="0,3,0"/>
<TextBlock Text="{StaticResource UcAuditSaleOrder_Rset}"/>
</StackPanel>
</button>
<button x:name="btnSearch" GrID.Row="2" Style="{StaticResource Toolbutton}" HorizontalAlignment="Right" VerticalAlignment="top" margin="0,20" > <StackPanel OrIEntation="Horizontal" > <Image WIDth="16" Height="16" Source="/ENPOT.distribution.Management;component/Resources/Imagesarch.png" margin="0,0"/> <TextBlock Text="{StaticResource UcAuditSaleOrder_SearchBtn}"/> </StackPanel> </button> </GrID> </border> </GrID> </ControlTemplate> </Setter.Value> </Setter> </Style> <!--搜索控件End-->
总结以上是内存溢出为你收集整理的Silverlight用户控件自定义,同事写的例子目前自己还没看懂,不过先留着全部内容,希望文章能够帮你解决Silverlight用户控件自定义,同事写的例子目前自己还没看懂,不过先留着所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)