XAML用户控件:重用相同的实例

时间:2014-11-07 16:18:20

标签: c# xaml silverlight

我正在使用C#开发Windows Phone Silverlight 8.1项目。我创建了一个自定义用户控件:

<UserControl x:Class="AppSeafileClient.Class.PivotHelpControl"
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:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">

<Grid x:Name="LayoutRoot">
    <StackPanel  Background="#FFCDC8C8">
        <TextBlock TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="Black">If you are having trouble with this app, you can use the switch below to record information about how you use the app to send back to me.</TextBlock>
        <toolkit:ToggleSwitch 
            x:Name="toggle_debug" 
            Content="Off" IsChecked="False"  
            Foreground="Black"
            Unchecked="toggle_debug_Unchecked"
            Checked="toggle_debug_Checked">
            <toolkit:ToggleSwitch.Header>
                <TextBlock Text="Information gathering" Foreground="Black" />
             </toolkit:ToggleSwitch.Header>            
        </toolkit:ToggleSwitch>
        <TextBlock TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="Black">Once you are done recording, add dome detail about the issue, then tap below to email the log back to me and I will be in touch :</TextBlock>
        <TextBox TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" Name="textblock_debug" AcceptsReturn="True" Height="150"></TextBox>
        <Button Name="debug_send" Click="debug_send_Click" FontSize="{StaticResource PhoneFontSizeNormal}" BorderBrush="Black" Foreground="Black">Send log</Button>
    </StackPanel>
</Grid>

现在,我想在我的应用程序中的2个不同页面上使用此控件。我使用以下代码在两页上添加控件:

<localClass:PivotHelpControl x:Name="myPivoteItemHelp" />

但是,如果我在page1上的文本框中添加文本,我继续第2页,我看不到文本。我认为控制是两次实施。

如何在2页上使用相同的控件(只有1个控件实例)?

由于

0 个答案:

没有答案