我目前正在調查在Expression Blend 4中的Silverlight項目中構建用戶控件。該控件具有用於用戶控件的相關聯的一組示例數據,並且數據在用戶控制。MainPage.xaml中的Silverlight用戶控件
當我將用戶控件放在主頁上時,示例數據不會出現在用戶控件中。這是正確的行爲,還是我設置/不設置的東西?我發現奇怪的是,當我編輯用戶控件時,數據與重建指示符(黃色感嘆號)一起出現在主頁面中。當我重建時,數據再次消失。
這是主頁代碼:
<UserControl
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:SilverlightApplication2" mc:Ignorable="d"
x:Class="SilverlightApplication2.MainPage"
Width="1200" Height="640">
<UserControl.Resources>
<local:MultiDayViewModel x:Key="MultiDayViewModelDataSource" d:IsDataSource="True"/>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White" d:DataContext="{d:DesignData /SampleData/TestSampleData.xaml}">
<Grid.RowDefinitions>
<RowDefinition Height="0.128*"/>
<RowDefinition Height="0.872*"/>
</Grid.RowDefinitions>
<StackPanel Margin="0,24,8,8" HorizontalAlignment="Right" Width="318" Orientation="Horizontal">
<Button Content="Daily"/>
<Button Content="Weekly"/>
</StackPanel>
<local:MultiDayView x:Name="MultiDayView" Margin="8" Grid.Row="1" DataContext="{Binding Calenar, Source={StaticResource MultiDayViewModelDataSource}}"/>
</Grid>
任何想法或方向將不勝感激。
謝謝。
運行時也不會顯示示例數據。我將這個問題作爲一個單獨的問題提出,但我感覺這兩個問題是相關的。任何線索? – Jason 2010-10-20 03:37:25