0
我想從現有視圖中創建一個擴展,其中我有一個文本控件列表,並且在新項目中我想使用此控件並將其中一個文本框更改爲單選按鈕。更改Silverlight視圖
使用MVVM可以輕鬆使用相同的代碼,而不必重複代碼,但對於XAML視圖,我發現沒有好的方法可以在不創建副本的情況下執行此更改。
例子:
與主用戶控制
<UserControl x:Class="SilverlightApplication4.MainPage" Name="test"
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">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<TextBlock>
asdfasdf
this is a test
</TextBlock>
<Button Height="120" Name="asdf" Content="This is a Button">
</Button>
</StackPanel>
</Grid>
</UserControl>
現在我有,我想改變的TextBlock別的東西第二個項目的核心工程。
<UserControl x:Class="SilverlightApplication1.MainPage"
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"
xmlns:core="clr-namespace:SilverlightApplication4;assembly=SilverlightApplication4" d:DesignHeight="300" d:DesignWidth="400">
<core:MainPage>
<!-- how do i change the type of child elements?-->
</core:MainPage>
</UserControl>