codingseb / Localization

A suite to localize C# and WPF projects easily based on file format you choose.
MIT License
36 stars 6 forks source link

Installing Costura Fody #11

Open rukshanfonseka opened 9 months ago

rukshanfonseka commented 9 months ago

When installing Costura ie because I want to create a one binary. The project won't compile as it fails to understand Tr in the XAML.

rukshanfonseka commented 9 months ago

I think this is because the version of Fody is newer when Costura is installed and so the project fails to compile.

codingseb commented 9 months ago

Apparently this is due to the fact that : To use Tr in xaml without namespace we need to export a namespace in the standard xaml namespace. This is done in the file AddWPFXAMLStandardNameSpace.cs

This only works when we use the corresponding assembly in an another assembly.

So as Costura repack all assemblies in one we need to access Tr with a namespace again in all xaml that will be repack in the same assembly by costura.

So with costura you need to replace all your Tr and other xaml markups defined in CodingSeb.Localization.WPF.

<Window x:Class="..."
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="..."
        xmlns:loc="clr-namespace:CodingSeb.Localization.WPF"> 
       <TextBlock Text="{loc:Tr TextId}" />
</Window>