View previous topic :: View next topic |
Author |
Message |
pavd
Joined: 08 Sep 2010 Posts: 9
|
Posted: Wed Sep 04, 2013 9:12 am Post subject: Using inherited wpf user controls /windows |
|
|
Hi,
I have two questions:
1) use inherited user controls in xaml. Like
<OperationalReports:BaseReport x:Class="Priva.Fusion.OperationalReports.ReaderReport" ...
Base report is only a code class:
public class BaseReport : UserControl
{
...
When scanning this type of user control the ReaderReport doesn't become visible in the globalizer workspace explore. Why?
2) Somewhat related to 1) I use devexpress windows in xaml like:
<dx:DXWindow x:Class="Priva.Fusion.OperationalReports.ProgressWindow"
When scanning this window the ProgressWindow doesn't become visible in the globalizers workspace explorer. Why? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Sep 05, 2013 2:18 am Post subject: |
|
|
I just tried to replicate this issue in the sample WpfApp project. I added a code only class called BaseControl with code:
Code: | namespace WpfApp
{
public partial class BaseControl : UserControl
{
public BaseControl()
{
}
}
} |
Then I added a UserControl class and changed it derive from the BaseControl with XAML:
Code: | <WpfApp:BaseControl x:Class="WpfApp.DerivedControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfApp="clr-namespace:WpfApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock Height="60" HorizontalAlignment="Left" Margin="54,62,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="152" />
</Grid>
</WpfApp:BaseControl> |
And code behind:
Code: | namespace WpfApp
{
public partial class DerivedControl : BaseControl
{
public DerivedControl()
{
InitializeComponent();
}
}
} |
I then scanned the project and the derived control showed up in the workspace as expected. Note that user controls will not be included in the Workspace if they don't include any localizable XAML. So if I hadn't added the TextBox to the derived control it would not have been converted and added to the workspace.
If you are still having problems and you can replicate the problem in the WpfApp sample project and send a zipped copy of the project to support@infralution.com then we would be happy to take a look. _________________ Infralution Support |
|
Back to top |
|
|
pavd
Joined: 08 Sep 2010 Posts: 9
|
Posted: Thu Sep 05, 2013 9:15 am Post subject: |
|
|
I did the same as in your reply.
Yes, now the DerivedControl is in the workspace but preview was not possible: I got E205 |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Sep 05, 2013 11:06 pm Post subject: |
|
|
Thanks for the sample project. It was in a somewhat strange state. The XAML for the Derived control had been converted to use the ResxExtension but the DerivedControl.resx file that should have been created when converting was not in the Project and didn't even exist.
The Globalizer workspace did not contain the DerivedControl target. Because the XAML had already been converted and the DerivedControl.resx file was missing, scanning again would not add it. I think you may have got into this situation because you had the Visual Studio project open when you were scanning and converting it. Globalizer changes the project when convert to add the resx file for the resources. If you have the project open in visual studio then you get asked to reload the project - if you click No then later save the visual studio project the changes made by Globalizer will be overwritten.
I added a new text box to the DerivedControl to replace the one that had already been converted then scanned again. This meant Globalizer converted the XAML and recreated the DerivedControl.resx. I then opened and built the project in Visual Studio and after reloading the Globalizer workspace was able to preview the control.
The E205 Error that you reported means that Globalizer is unable to find the type associated with a form or control. This usually means that you have not built the assembly. It may also occur if you make changes to a project and rebuild it while Globalizer is open. In this case Globalizer may still be using the previous version of the assembly. To force Globalizer to use the latest built version of the assembly use the File > Save and Reopen menu to reload the workspace. _________________ Infralution Support |
|
Back to top |
|
|
pavd
Joined: 08 Sep 2010 Posts: 9
|
Posted: Fri Sep 06, 2013 12:48 pm Post subject: |
|
|
Thanks, now it works, but several xaml's didn;t work properly because 1 or more of the following:
1) no default constructor was present
2) MinWidth and MinHeight were not specified
3) All texts already were resource string in a separate resx file
4) some default constructors access service code which is not available in preview mode and so causing exception
5) several problems with static resources causing errors.
Our application already has a lot of xaml all containing strings in separate resx file (which are shared with more then one xaml). I think in particular issue 3) is a lot of work to get most of xaml;s previewable.
Do you have a solution for issue 3) |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Sep 06, 2013 11:42 pm Post subject: |
|
|
By 3) do you mean that the text is being set from resx resources but using a method other than the ResxExtension? Globalizer should still scan the resources in the resx file in this case - however the form would not be previewable. It would probably be possible to change the Resx Type to WPF Window/Control in the target properties in Globalizer to allow the form to be previewed - but it still would not support dynamic language changing - which requires using the ResxExtension.
The section in help called "Using the Preview Window" provides some coding guidelines to ensure that previews will work correctly. If this is too much work at the moment you can always just turn off the Translator Preview function (in the root Workspace target properties) and just use Globalizer as a text translation tool until you can fix these issues. _________________ Infralution Support |
|
Back to top |
|
|
|