change the background image of ModernActionStep title and subtitle

Any SharpSetup related discussions are welcome here including but not limited to questions about functionality, suggestions for improvements and technical questions.
reem
Posts: 7
Joined: Thu Jan 26, 2017 9:10 am

change the background image of ModernActionStep title and subtitle

Postby reem » Mon Feb 20, 2017 11:54 am

Hello Tomasz,

it is me again with a new question :D
I have read all posts related to change images in the installer gui, one of them is this: http://sharpsetup.eu/forum/viewtopic.phpf=3&t=136&p=239&
and i couldn't manage to change the background image in ModernActionStep. I want to keep the properties Title and Subtitle, or reuse the labels in a style and apply it to all steps derived from ModernActionStep.

how can I do this?

Thanx,
Reem

tomasz_grobelny
Posts: 461
Joined: Sat May 22, 2010 1:26 pm

Re: change the background image of ModernActionStep title and subtitle

Postby tomasz_grobelny » Mon Feb 20, 2017 9:33 pm

Just to clarify: are we talking about WinForms or WPF GUI?

reem
Posts: 7
Joined: Thu Jan 26, 2017 9:10 am

Re: change the background image of ModernActionStep title and subtitle

Postby reem » Tue Feb 21, 2017 8:08 am

WPF GUI


reem
Posts: 7
Joined: Thu Jan 26, 2017 9:10 am

Re: change the background image of ModernActionStep title and subtitle

Postby reem » Wed Feb 22, 2017 8:49 am

Thanx for your replies.
Actually, I have come accross these threads, but my problem is that the title and sub-title labels are overridden and I dont want to use new labels to keep the consistency between steps and for localizing the labels.
Is there a way to get these labels to appear without adding new labels?
Thank you in advance.

tomasz_grobelny
Posts: 461
Joined: Sat May 22, 2010 1:26 pm

Re: change the background image of ModernActionStep title and subtitle

Postby tomasz_grobelny » Wed Feb 22, 2017 10:30 pm

I am still not sure I understand the problem at hand. Let me try to explain the best way I can. If that does not answer the question please let me know of the steps you are executing and which requirement is not achieved. Note that I might be unavailable next week.

As mentioned in the first thread to change the picture you need to replace the whole control template. For top picture on LicenseStep it would look like this:

Code: Select all

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ss="http://sharpsetup.eu/schemas/xaml/wpfui/2012"
                    xmlns:p="clr-namespace:Gui.Properties"
                    xmlns:gui="clr-namespace:Gui"
                    >
    <Style TargetType="{x:Type gui:LicenseStep}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type gui:LicenseStep}">
                    <DockPanel>
                        <Label DockPanel.Dock="Top" BorderThickness="0" Height="62">
                            <StackPanel Orientation="Vertical">
                                <Label Content="{TemplateBinding Title}" Background="Transparent" FontWeight="Bold" Margin="10,4,10,0" Padding="0" />
                                <Label Background="Transparent" Margin="30,5,10,0" Padding="0">
                                    <TextBlock TextWrapping="Wrap" Text="{TemplateBinding Subtitle}"/>
                                </Label>
                            </StackPanel>
                            <Label.Background>
                                <ImageBrush Stretch="Fill">
                                    <ImageBrush.ImageSource>
                                        <Binding>
                                            <Binding.Source>
                                                <x:Static Member="p:Resources.YourNewBannerResource" />
                                            </Binding.Source>
                                            <Binding.Converter>
                                                <base:BitmapToBitmapSourceConverter/>
                                            </Binding.Converter>
                                        </Binding>
                                    </ImageBrush.ImageSource>
                                </ImageBrush>
                            </Label.Background>
                        </Label>
                        <Border HorizontalAlignment="Stretch" Height="1" DockPanel.Dock="Top" Background="DarkGray" SnapsToDevicePixels="True" />
                        <Border HorizontalAlignment="Stretch" Height="1" DockPanel.Dock="Top" Background="White" SnapsToDevicePixels="True" />
                        <Border Padding="10">
                            <ContentPresenter />
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>


As you can see the template uses the original Title/Subtitle properties (with TemplateBinding) - with this template you are only changing the view part, not the model. I am not a WPF expert and to the best of my knowledge in the current state of things you need to replace whole template (including Label controls). On the other hand if it should be possible to use TemplateBinding to not only bind the text but also picture... but this is something to be considered for future versions.

reem
Posts: 7
Joined: Thu Jan 26, 2017 9:10 am

Re: change the background image of ModernActionStep title and subtitle

Postby reem » Thu Feb 23, 2017 11:25 am

Apparently I was missing the binding with Title and Sub-title properties.
now it works, thanx alot


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest