好的......使用代碼的PivotItem內容?
這讓我感到困惑......我有辦法想到這樣做......但我不知道從哪裏開始。
我想在示例代碼中添加一個PivotItem ...
for (int i = 0; i < App.Accounts.Items.Count; i++)
{
PivotItem pvItem = new PivotItem();
pvItem.Header = App.Accounts.Items[i].Username;
pvItem.Content = "";
pivotControl.Items.Add(pvItem);
}
現在,在那裏我遇到了我的問題是設置PivotItem內容。
我想設置這個代碼內容:
<ListBox x:Name="Accounts" Margin="0,0,-12,0">
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<StackPanel Width="455" x:Name="accWidth">
<TextBlock Text="Personal Account" FontSize="32" Margin="0,0,0,0" TextAlignment="Center" />
<toolkit:ToggleSwitch Header="Signed On" Tag="{Binding Tag}" IsChecked="{Binding SignedOn}" Checked="ToggleSwitch_Checked" Unchecked="ToggleSwitch_Unchecked" />
<toolkit:ToggleSwitch Header="Invisible Login" Tag="{Binding Tag}" IsChecked="{Binding InvisibleLogin}" Checked="ToggleSwitch_Checked" Unchecked="ToggleSwitch_Unchecked" />
<toolkit:ToggleSwitch Header="Show as Windows Phone 7" Tag="{Binding Tag}" IsChecked="{Binding MobileLogin}" Checked="ToggleSwitch_Checked" Unchecked="ToggleSwitch_Unchecked" />
</StackPanel>
</StackPanel>
</ListBox>
我能想到做的就是:不知怎的,創造在它上面的代碼中的另一個.XAML片,不過,我會怎樣聲明:
pvItem.Content = XAMLSheet.xaml;
除非有另一種方式,我認爲這是我必須這樣做。
我還需要事件來工作和標籤應該使用代碼而不是像我原來的數據綁定應用。
我試着這樣做,但是,那隻能說明它作爲文本不代碼...
pvItem.Content = "<TextBlock Text=\"Hello\" />";
謝謝。