WEB开发网      婵傜晫鐝總钘夊瀻娴滎偓绱掓担鐘垫畱娑撯偓娴犺棄鍨庢禍顐fЦ閹存垳婊戦惃鍕娴犺棄濮╅崝娑崇幢鐠囧嘲鍨庢禍锟� ---閿曪拷
开发学院图形图像Flash 在Silverlight2 Beta2中开发自定义控件 阅读

在Silverlight2 Beta2中开发自定义控件

 2008-11-07 11:47:28 来源:WEB开发网 閵嗭拷閸戝繐鐨€涙ぞ缍�婢х偛銇囩€涙ぞ缍�閵嗭拷  閸忚櫕鏁炴Λ娆愬盁閸楀洨娈戝顔煎触
核心提示: Page.xaml中更改控件的属性如下:<custom:CarySLCustomControl Width="250" Height="150" Background="LightGreen"> <custom:

Page.xaml中更改控件的属性如下:

 <custom:CarySLCustomControl Width="250" Height="150" Background="LightGreen">
   <custom:CarySLCustomControl.Content>
     <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
      <Ellipse Width="75" Height="75" Margin="10">
       <Ellipse.Fill>
        <RadialGradientBrush GradientOrigin="0.25,0.25">
         <GradientStop Offset="0.25" Color="LightGray" />
         <GradientStop Offset="1.0" Color="DarkGoldenrod" />
        </RadialGradientBrush>
       </Ellipse.Fill>
      </Ellipse>
      <TextBlock Text="Cary Click" VerticalAlignment="Center" />
  </StackPanel>
      </custom:CarySLCustomControl.Content>
</custom:CarySLCustomControl>

效果如下图:

在Silverlight2 Beta2中开发自定义控件

四:添加一个单击事件

WPF中支持向下和向下的事件路由,路由事件的路由可有效地向上遍历或向下遍历树,这要取决于该事件是隧道路由事件还是冒泡路由事件,而Silverlight中的路由事件只支持冒泡路由策略。下面我们为该控件添加一个单击事件,代码如下:

上一页  1 2 3 4 5 6  下一页

Tags:Silverlight 开发

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接