Click here to Skip to main content
15,881,715 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF EF Core 6 DP Question Pin
Richard Deeming25-Jul-23 21:41
mveRichard Deeming25-Jul-23 21:41 
GeneralRe: WPF EF Core 6 DP Question Pin
Kevin Marois27-Jul-23 19:27
professionalKevin Marois27-Jul-23 19:27 
GeneralRe: WPF EF Core 6 DP Question Pin
Richard Deeming30-Jul-23 21:55
mveRichard Deeming30-Jul-23 21:55 
QuestionWPF xceed CheckcComboBox SelectAll Text Pin
Kevin Marois20-Jun-23 18:17
professionalKevin Marois20-Jun-23 18:17 
AnswerRe: WPF xceed CheckcComboBox SelectAll Text Pin
Richard Deeming20-Jun-23 20:53
mveRichard Deeming20-Jun-23 20:53 
GeneralRe: WPF xceed CheckcComboBox SelectAll Text Pin
Kevin Marois21-Jun-23 10:32
professionalKevin Marois21-Jun-23 10:32 
QuestionList of Images Pin
Kevin Marois9-Jun-23 13:47
professionalKevin Marois9-Jun-23 13:47 
QuestionChange Image URL's Assembly At Runtime Pin
Kevin Marois6-Jun-23 7:15
professionalKevin Marois6-Jun-23 7:15 
I have a WPF that's branded four ways, say App1, App2, App3, and App4.

I change the name of the output assembly like this:
<AssemblyName Condition="'$(Configuration)' == 'Release App1'">App1</AssemblyName>
<AssemblyName Condition="'$(Configuration)' == 'Release App2'">App2</AssemblyName>
<AssemblyName Condition="'$(Configuration)' == 'Release App3'">App3</AssemblyName>
<AssemblyName Condition="'$(Configuration)' == 'Release App4'">App4</AssemblyName>
This results in the compiled assembly being named according to the brand.

I have images all over the app like this:
<Image x:Name="myImage"
        Stretch="None"
        Width="15"
        Height="15" 
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Source="/App1;component/Images/My_Image.png" />

In some cases, in Release builds, the images fail to appear. From what I can see, in Release builds the source can't find the assembly name, so the image fails to load. I verified this by renaming all of the output assemblies in the <assemblyname> tags above to "App1" and it works.

So I've implemented code like this:
private BitmapImage _MyImage;
public BitmapImage MyImage
{
    get { return _MyImage; }
    set
    {
        if (_MyImage != value)
        {
            _MyImage = value;
            RaisePropertyChanged("MyImage");
        }
    }
}
and
        private void SetupBranding()
        {
            var imageFolder = "";

if BRAND_APP1
            imageFolder = "App1";
elif BRAND_APP2
            imageFolder = "App2";
elif BRAND_APP3
            imageFolder = "App3";
elif BRAND_APP4
            imageFolder = "App4";
<h1>endif</h1>

            // Get the assembly name
            string assemblyName = Assembly.GetExecutingAssembly().GetName().Name;

            // Form the path to the assembly's image folder
            var path = $"/{assemblyName};component/Images/Brand/{imageFolder}/My_Image.png";
            MyImage = new BitmapImage(new Uri(path, UriKind.Relative));
        }

This seems to work fine, but I have do do this anywhere I want to use brand-specific images. I'm wondering of there's a better way? Is there a way to handle hard coded pack URI such has:
Source="/App1;component/Images/My_Image.png"

One other concern is that, while most of this is done in the Windows and Views, there are some URI's specified in styles.

Thanks
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.

AnswerRe: Change Image URL's Assembly At Runtime Pin
Gerry Schmitz6-Jun-23 15:52
mveGerry Schmitz6-Jun-23 15:52 
Questionc# Spotify API not returning correctly. Pin
elfenliedtopfan52-Jun-23 18:03
elfenliedtopfan52-Jun-23 18:03 
AnswerRe: c# Spotify API not returning correctly. Pin
Pete O'Hanlon4-Jun-23 8:42
mvePete O'Hanlon4-Jun-23 8:42 
AnswerRe: c# Spotify API not returning correctly. Pin
jschell5-Jun-23 5:01
jschell5-Jun-23 5:01 
QuestionNeed help please regarding your awesome WPF MultiComboBox project :) Pin
Member 1160463425-May-23 5:21
Member 1160463425-May-23 5:21 
AnswerRe: Need help please regarding your awesome WPF MultiComboBox project :) Pin
jeron125-May-23 5:50
jeron125-May-23 5:50 
AnswerRe: Need help please regarding your awesome WPF MultiComboBox project :) Pin
Richard Deeming25-May-23 21:28
mveRichard Deeming25-May-23 21:28 
QuestionNavigationControl - Part 3 Pin
Kevin Marois14-May-23 8:01
professionalKevin Marois14-May-23 8:01 
AnswerRe: NavigationControl - Part 3 Pin
Richard Deeming14-May-23 21:40
mveRichard Deeming14-May-23 21:40 
GeneralRe: NavigationControl - Part 3 Pin
Kevin Marois15-May-23 17:14
professionalKevin Marois15-May-23 17:14 
QuestionBubbling Event Question Pin
Kevin Marois9-May-23 14:32
professionalKevin Marois9-May-23 14:32 
AnswerRe: Bubbling Event Question Pin
Gerry Schmitz12-May-23 5:28
mveGerry Schmitz12-May-23 5:28 
GeneralRe: Bubbling Event Question Pin
Kevin Marois12-May-23 5:35
professionalKevin Marois12-May-23 5:35 
GeneralRe: Bubbling Event Question Pin
Gerry Schmitz12-May-23 5:46
mveGerry Schmitz12-May-23 5:46 
GeneralRe: Bubbling Event Question Pin
Kevin Marois12-May-23 6:16
professionalKevin Marois12-May-23 6:16 
AnswerRe: Bubbling Event Question Pin
Kenneth Haugland14-May-23 9:55
mvaKenneth Haugland14-May-23 9:55 
GeneralRe: Bubbling Event Question Pin
Kevin Marois14-May-23 10:40
professionalKevin Marois14-May-23 10:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.