我需要在我的应用中显示弹出窗口。所以我有用户控件来制作自定义弹出窗口。每个弹出窗口都会显示不同的消息和不同的按钮组。我可以重复使用相同的xaml来改变文本并创建新按钮吗?或者我是否必须创建单独的用户控件?
<Grid Height="250" Width="480">
<Canvas Margin="0,0,0,0">
<Canvas.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF121111" Offset="1"/>
</LinearGradientBrush>
</Canvas.Background>
<Button Content="Buy" x:Name="buttonBuy" Click="btnBuyNow_Click" BorderThickness="0" Style="{StaticResource UserControlBuy}" MinWidth="96" MinHeight="98" FontFamily="{StaticResource CicleFina}" FontSize="18.667" Canvas.Left="189" Canvas.Top="141" Height="98" Width="96" Foreground="#FF0E0C0C">
<Button.Background>
<ImageBrush ImageSource="Images/02/but_bg_trial_buy.png"/>
</Button.Background>
</Button>
<TextBlock TextWrapping="Wrap" FontSize="21.333" Padding="10" Text="Your trial period is over. Please purchase the full version" Height="141" Width="479" Foreground="#D48394" FontFamily="{StaticResource PeaSnow}" TextAlignment="Center" d:LayoutOverrides="Width, Height"/>
</Canvas>
</Grid>
这就是我在应用程序中调用弹出窗口的方式。
Popup popup = new Popup();
BuyNowUserControl content = new BuyNowUserControl(popup);
// set the width of the popup to the width of the screen
content.Width = System.Windows.Application.Current.Host.Content.ActualWidth;
popup.Child = content;
popup.VerticalOffset = 300;
popup.IsOpen = true;
谢谢
Alfah
答案 0 :(得分:3)
是的,您可以重复使用它们。我会做以下事情:
实现这一点实际上是相当多的工作,所以值得评估好处。