Visual studio extension resource files

655 views Asked by At

I have developed a visual studio extension and I have a custom button that I want to style using PNG images, but the image files/resource files wont show while in action and the button is blank.

enter image description here

I have a custom button template.

<Style x:Key="openFilebtn" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid Name="bgGrid">
                            <Image Name="btn_bg"  Source="/vsPlayer;component/Resources/open.png"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsDefaulted" Value="True">
                                <Setter Property="Source" TargetName="btn_bg" Value="/vsPlayer;component/Resources/open.png"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Source" TargetName="btn_bg" Value="/vsPlayer;component/Resources/open_hover.png"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Source" TargetName="btn_bg" Value="/vsPlayer;component/Resources/open.png"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Source" TargetName="btn_bg" Value="/vsPlayer;component/Resources/open.png"/>
                                <Setter Property="Opacity" TargetName="btn_bg" Value="0.5"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
1

There are 1 answers

0
Chris W. On BEST ANSWER

So like I was saying, always make sure you have your build action property set correctly on assets like images you're including in the build. In your case, setting it to Resource does the trick.

Glad you got your remedy, cheers!