I need to display pop ups in my app. So I have user controls to make customised pop ups. Every pop up shows a different message and different set of buttons. Can I reuse the same xaml to alter the text and make new buttons? Or do I have to create seperate usercontrols?
<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>
This is how i’ve called the pop up in the app. .
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;
Thanks
Alfah
Yes, you can re-use them. I would do the following:
It is actually quite a bit of work to achieve this, so worth evaluating the benefit.