0
在Flash中,可以指向磁盤上的文件以將表單與類名稱可以不同於表單名稱的類相關聯,以便可以將多個表單到同一班。是否有可能將相同的代碼隱藏與閃存中的多個類在silverlight中關聯
在Silverlight中是否有可能以某種方式包括通過手動攻擊vs studio項目xml文件?
在Flash中,可以指向磁盤上的文件以將表單與類名稱可以不同於表單名稱的類相關聯,以便可以將多個表單到同一班。是否有可能將相同的代碼隱藏與閃存中的多個類在silverlight中關聯
在Silverlight中是否有可能以某種方式包括通過手動攻擊vs studio項目xml文件?
它使用繼承來執行。您可以在基本控件中定義所有需要的內容,並且派生控件使用此代碼。比如你要定義事件處理程序,將被用於所有控件:
定義在基類的事件處理程序 - BaseControl.xaml.cs
namespace SilverlightApp
{
public partial class BaseControl : UserControl
{
public BaseControl()
{
InitializeComponent();
}
// The event handler that used by derived classes
protected void Button_Click(object sender, RoutedEventArgs e)
{
// your implementation here
}
}
}
BaseControl.xaml
<UserControl x:Class="SilverlightApp.BaseControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<!-- your implementation here if needed -->
</UserControl>
MyControl1.xaml.cs - 定義從BaseControl繼承的新控件。你只需要指定基類
namespace SilverlightApp
{
public partial class MyControl1 : BaseControl
{
public MyControl1()
{
InitializeComponent();
}
}
}
MyControl1.xaml
<local:BaseControl x:Class="SilverlightApp.MyControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SilverlightApp"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<!-- button uses event handler from the base class -->
<Button Content="My button" Click="Button_Click" />
</Grid>
</local:BaseControl>
希望它你是什麼意思。
非常感謝你會嘗試。 – user310291 2011-04-27 20:52:42