Quantcast
Channel: WPF Localization Extension
Viewing all 286 articles
Browse latest View live

New Comment on "Supported platforms"

$
0
0
Doesn't it work with .Net 4.5? :) I see at system requirements it requires AT LEAST 3.5, but here I do not see it. Will it work fine on my 4.5 app's?

New Post: Localization don't work in ClickOnce deployment

$
0
0
Hello,

i've installed the localization extension 2.2.0 and everthing works fine. But if i deploy my program via ClickOnce, the changing of the language don't work anymore.

I'm changing the language in code with
LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("de");
//or
LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("en");
...binding of the text:
{lex:Loc KeyName}
What i'm doing wrong? Do i need a special code for clickonce? Thanks for helping!

New Post: Update the Idiot's Guide to using WPF Localization Extenstion

New Post: New Release?

$
0
0
There have been some good updates on GitHub since the last release. Is there a plan to update the NuGet package soon? I prefer to wait for the NuGet packages as it indicates that it's stable.

New Post: Key binding

$
0
0
Yes, you can. Use the LocProxy object. Example:
<lex:LocProxy x:Name="proxy" Source="{Binding Name}"/>
<TextBlock Text="{Binding Result, ElementName=proxy}"/>

Commented Issue: Memory leaks in ParentChangedNotifier [9277]

$
0
0
I'm currently writing an application which has multiple Windows which can be dynamically created, destroyed and recreated by the user. I noticed that the first instance of a Window is kept in memory until the application is destroyed, meaning that I will
often have two instances of the same Window in memory at any one time.

After a bit of hunting I've tracked this down to ParentChangedNotifierHelper.cs in the WPF Localization Extension. In the GetValueOrRegisterParentNotifier<T> a reference to the first instance of the view is added in the following block...



parentNotifiers.Add(target, new ParentChangedNotifier((FrameworkElement)depObj, () =>
{
ParentChangedAction(target);
}));


This reference hangs around forever and so the first instance of the view is never unloaded from memory.

I've reproduced the issue in very simple application (code available if needed). The application simply creates an instance of a view containing a localized Label.

Am I doing something wrong? Is there any way I can work around this?

Any help would be much appreciated!
Comments: In a nested environment like below, the issue still exists as stated above. Leak is introduced due to the full specification of the header text, but the key is not found if not specified. Default values are provided and working on the main group. If needed I will try to build a small example. The example is using DevExpress. <dxdo:LayoutGroup Caption="{lex:Loc CustomerGroup}" > <dxdo:LayoutControlItem Caption="{lex:Loc CustomerContact}"> <dxg:LookUpEdit DisplayMember="DisplayName" ItemsSource="{Binding CustomerContacts}" PopupWidth="1000" AutoPopulateColumns="False" TextWrapping="Wrap" NullText="{lex:Loc NoReference}"> <dxg:LookUpEdit.PopupContentTemplate> <ControlTemplate> <dxg:GridControl Name="PART_GridControl" AutoExpandAllGroups="True"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="FullName" Header="{lex:Loc LocalizeTest:TestLoc:ContactName}" Width="150" SortIndex="0"/>

Created Task: Drop Support for WP7 / Silverlight [9315]

$
0
0
yes, thats right. WP7 is dead and Silverlight felt into the darkness.
why now? we can't build WP7 anymore and silverlight doesn't make any sense anymore.

What do you think?

Updated Wiki: Home

$
0
0

The Localization Extension...

... is the easiest way to localize any type of DependencyProperties or native Properties on DependencyObjects under WPF & Silverlight.

Feature Demo:

Version 2.2.0 is ready - Right on time for Christmas :-)

Structure of version 2.0.0 and higher

Products that use this Solution:

SAPSAP Crystal Reports, Version for Visual Studio .NET

Features:

  • First of all: ITS FREE (and will stay free)
  • Obtain stable results in
    • WPF applications using .NET 3.5 and higher
    • New: Silverlight 5.0 applications
    • New: Windows Phone 7.x applications
  • New: Localization source/provider can be changed freely at arbitrary nodes
    • Use the Provider property in LocalizeDictionary to change the provider for the particular sub tree
    • Use the DefaultProvider property to set the provider for the whole application
    • Built-in RESX provider for resource file lookup (Default) - fully backward compatible to older versions of this extension
    • Interface for custom providers
    • Notification about provider changes and errors
    • Get the list of all available cultures from a provider - or just take the bindable merged list from LocalizeDictionary
    • CSV provider project in the Tests folder as an example for custom providers
  • Supports binding-like write style like "Text = {lex:LocText ResAssembly:ResFile:ResKey}"
    • Define a default assembly and / or resource file to reduce the key to ResAssembly::ResKey, ResFile:ResKey or even ResKey
    • If no key is specified, the Name and Property Name of the target are used (e.g. MyButton_Content)
    • Default assembly, dictionary and culture can be changed dynamically
    • Default assembly and dictionary inherit along the visual tree and can be redefined at each node
  • It is available at designtime (MS Expression Blend 3.0 & 4.0, MS VisualStudio 2008 & 2010
    • not for dynamic loaded assemblies which only can be found at runtime and as long the resource (.resx) is built at designtime
    • Even for Silverlight!
    • No extra preview application needed
    • Offers a DesignValue Property to support custom values during design mode
  • Full support of various application scenarios
    • Works with normal dependency properties
    • Works with normal properties (e.g. Ribbon)
    • Works with control/data templates
  • Various culture setup features
    • Works with the .resx-fallback mechanism (e.g. en-us -> en -> invariant culture)
    • Supports culture forcing (e.g. "this object has to be in english all the time")
    • Buffering allows fast switching of the language at runtime
    • Offers a design language for visual testing at designtime
    • Offers a "SpecificCulture" to use as IFormatProvider (e.g. (123.20).ToString(LocalizeDictionary.SpecificCulture) = "123.20" or "123,20")
    • Does not alter the culture on Thread.CurrentCulture or Thread.CurrentUICulture (can be changed easily)
  • Code behind features:
    • Can be used in code behind to bind localized values to dynamic generated controls
    • Implements INotifyPropertyChanged for advanced use
    • Offers some functionality to check and get resource values in code behind (e.g. ResolveLocalizedValue)
  • Easy to use
    • Can be used with any resource file (.resx) accross all assemblies (also the dynamic loaded one at runtime)
    • Does not need any initializing process (like "call xyz to register a special localize dictionary")
    • Can localize any type of data type, as long a TypeConverter exists for it
  • Example extensions included for
    • Formating e.g. "this is the '{0}' value" (not bindable at the moment)
    • Prefix and suffix values (currently with LocText extension)
    • Upper and lower Text
  • Last, but not least
    • Does not create any memory leaks
    • Leaves the UID property untouched
    • Does not need an additional build task
    • Is in use in various productive systems

Get the latest NuGet package:

https://nuget.org/packages/WpfLocalizeExtension/

Get the source code:

https://github.com/SeriousM/WPFLocalizationExtension

Documentation & Tutorial

Documentation

Localization Tools:

ResXManager (Visual Studio Plugin and StandAlone)
Zeta Resource Editor (Freeware)

You can do a donation to me and my work.
It would be very nice of you :)
PayPal - The safer, easier way to pay online!

Please let me know your Feedback or send me a message if you are using this extension in your projects!
It would be nice if you would call me your company and whether i have the permission to set it on the references.


NEWS

20131215: Version 2.2.0 ready for download

20131122: Version 2.2.0 Beta ready for download

20130828: Version 2.1.4 ready for download

20130408: Version 2.1.3 ready for download

20121112: Version 2.1.2 ready for download

20121017: Version 2.1.1 ready for download

20120706: Version 2.1.0 ready for download

20120626: Beta 2.1.0 ready for download

20120620: Version 2.0.0 ready for download

20120619: Beta 2.0.0 ready for download

20120615: We got a documentation! ...ehm - finally :-)

20120614: The Localization Extension is now also supporting Silverlight 5.0 applications! Check out the latest source at GitHub or NuGet package

20120521: I'm proud to announce that WPF Localization Extension is prepared for the future! It's now build on top of XAML Markup Extensions by MrCircuit

20120116: NuGet Package arrived! https://nuget.org/packages/WpfLocalizeExtension/

20111103: I've added the source code to Github: https://github.com/SeriousM/WPFLocalizationExtension
Now can everyone make a fork easily! go for it :)

20110725: The SVN Repository (Source Code Section) is now updated. (the project is still alive and will be monitored well by me)

Released: v2.2.1 (May 12, 2014)

$
0
0
  • Issue #9277
  • Issue #9292
  • Issue #9311
  • Issue #9312
  • Issue #9313
  • Issue #9314

Created Release: v2.2.1 (Mai 12, 2014)

$
0
0
  • Issue #9277
  • Issue #9292
  • Issue #9311
  • Issue #9312
  • Issue #9313
  • Issue #9314

Closed Issue: "key: " in designer [9314]

$
0
0
Since it made this new version completely useless, I did some checking myself and found the problem of this issue. It isn't that hard to fix actually.

In the ResxLocalizationProviderBase there is a function GetResourceManager that is not working correctly.

There is this line (line 248):
```
var dir = Path.GetDirectoryName(process.Modules[0].FileName);
```

This doesn't work for x64 processes when the host process is x86 (and the other way around).
This is easily solved through WMI (the only way that works afaik):

Create a function in the same file:
```
/// <summary>
/// Get the executable path for both x86 and x64 processes.
/// </summary>
/// <param name="processId">The process id.</param>
/// <returns>The path if found; otherwise, null.</returns>
private static string GetExecutablePath(int processId)
{
const string wmiQueryString = "SELECT ProcessId, ExecutablePath, CommandLine FROM Win32_Process";
using (var searcher = new ManagementObjectSearcher(wmiQueryString))
using (var results = searcher.Get())
{
var query = from p in Process.GetProcesses()
join mo in results.Cast<ManagementObject>()
on p.Id equals (int)(uint)mo["ProcessId"]
where p.Id == processId
select new
{
Process = p,
Path = (string)mo["ExecutablePath"],
CommandLine = (string)mo["CommandLine"],
};
foreach (var item in query)
{
return item.Path;
}
}
return null;
}
```

Then, change line 248 from above to:
```
var dir = Path.GetDirectoryName(GetExecutablePath(process.Id));
if (String.IsNullOrWhiteSpace(dir))
continue;
```

However, there is other major issue in this same function.

Let's start with the first. There are foreach loops over the files:
```
foreach (var f in files)
```

There are a couple of issues I'm having with both these lines. The first being that it copies everything from every subdirectory. I have a subdirectory that stores temp files (a total of 12GB of small files). It takes 35 minutes to fully copy the folder that is of zero interest to this library. After all, it only needs two different file types, and the exe's and dll's of the assembly. So, the first change I made for both foreach loops is this:

```
foreach (var f in files.Where(x => !String.IsNullOrWhiteSpace(x)))
{
if (!(f.EndsWith(".resx", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) &&
!dir.Equals(Path.GetDirectoryName(f), StringComparison.OrdinalIgnoreCase)) // We aren't bothered with other files
continue;

// The other code
```

Then, there is this bit of code (283-288):
```
var dst = Path.Combine(assemblyDir, f.Replace(dir + "\\", ""));

var dstDir = Path.GetDirectoryName(dst);
if (!Directory.Exists(dstDir))
Directory.CreateDirectory(dstDir);
File.Copy(f, dst, true);
```

Since the generated cache folder is already quite long (C:\Users\UserName\AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache\gx43qkl1.wag\fdty5ini.grk\tmp), it easily goes over the max file path length (250). This caused the function to crash. Honestly, I don't care about one or two files that aren't able to be copied and thus disabling the whole preview so I made some changes too for this bit:
```
try
{
var dst = Path.Combine(assemblyDir, f.Replace(dir + "\\", ""));

var dstDir = Path.GetDirectoryName(dst);
if (String.IsNullOrWhiteSpace(dstDir))
continue;

if (!Directory.Exists(dstDir))
Directory.CreateDirectory(dstDir);
File.Copy(f, dst, true);
}
// ReSharper disable once EmptyGeneralCatchClause
catch { } // Ignore exceptions so the designer can continue to work.
```

So, here is the request to the author to fix this in the version on NuGet so I can continue to use that one. I don't mind editing code but it would be nice if it worked out of the box.

Thanks for all your hard work on this, we've been using it for a while now, but in my opinion it's current state is worse than what it is a year ago.
I also don't understand the reason why you want to put LocTextUpper etc on obsolete. Using converters isn't always an option when you need multiple converters (and I don't like chaining converters).

There are also some data errors now:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.FrameworkElement', AncestorLevel='1''. BindingExpression:Path=Parent; DataItem=null; target element is 'ContextMenu' (Name='MainContextMenu'); target property is 'Parent' (type 'DependencyObject')

Edited Issue: "key: " in designer [9314]

$
0
0
Since it made this new version completely useless, I did some checking myself and found the problem of this issue. It isn't that hard to fix actually.

In the ResxLocalizationProviderBase there is a function GetResourceManager that is not working correctly.

There is this line (line 248):
```
var dir = Path.GetDirectoryName(process.Modules[0].FileName);
```

This doesn't work for x64 processes when the host process is x86 (and the other way around).
This is easily solved through WMI (the only way that works afaik):

Create a function in the same file:
```
/// <summary>
/// Get the executable path for both x86 and x64 processes.
/// </summary>
/// <param name="processId">The process id.</param>
/// <returns>The path if found; otherwise, null.</returns>
private static string GetExecutablePath(int processId)
{
const string wmiQueryString = "SELECT ProcessId, ExecutablePath, CommandLine FROM Win32_Process";
using (var searcher = new ManagementObjectSearcher(wmiQueryString))
using (var results = searcher.Get())
{
var query = from p in Process.GetProcesses()
join mo in results.Cast<ManagementObject>()
on p.Id equals (int)(uint)mo["ProcessId"]
where p.Id == processId
select new
{
Process = p,
Path = (string)mo["ExecutablePath"],
CommandLine = (string)mo["CommandLine"],
};
foreach (var item in query)
{
return item.Path;
}
}
return null;
}
```

Then, change line 248 from above to:
```
var dir = Path.GetDirectoryName(GetExecutablePath(process.Id));
if (String.IsNullOrWhiteSpace(dir))
continue;
```

However, there is other major issue in this same function.

Let's start with the first. There are foreach loops over the files:
```
foreach (var f in files)
```

There are a couple of issues I'm having with both these lines. The first being that it copies everything from every subdirectory. I have a subdirectory that stores temp files (a total of 12GB of small files). It takes 35 minutes to fully copy the folder that is of zero interest to this library. After all, it only needs two different file types, and the exe's and dll's of the assembly. So, the first change I made for both foreach loops is this:

```
foreach (var f in files.Where(x => !String.IsNullOrWhiteSpace(x)))
{
if (!(f.EndsWith(".resx", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) &&
!dir.Equals(Path.GetDirectoryName(f), StringComparison.OrdinalIgnoreCase)) // We aren't bothered with other files
continue;

// The other code
```

Then, there is this bit of code (283-288):
```
var dst = Path.Combine(assemblyDir, f.Replace(dir + "\\", ""));

var dstDir = Path.GetDirectoryName(dst);
if (!Directory.Exists(dstDir))
Directory.CreateDirectory(dstDir);
File.Copy(f, dst, true);
```

Since the generated cache folder is already quite long (C:\Users\UserName\AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache\gx43qkl1.wag\fdty5ini.grk\tmp), it easily goes over the max file path length (250). This caused the function to crash. Honestly, I don't care about one or two files that aren't able to be copied and thus disabling the whole preview so I made some changes too for this bit:
```
try
{
var dst = Path.Combine(assemblyDir, f.Replace(dir + "\\", ""));

var dstDir = Path.GetDirectoryName(dst);
if (String.IsNullOrWhiteSpace(dstDir))
continue;

if (!Directory.Exists(dstDir))
Directory.CreateDirectory(dstDir);
File.Copy(f, dst, true);
}
// ReSharper disable once EmptyGeneralCatchClause
catch { } // Ignore exceptions so the designer can continue to work.
```

So, here is the request to the author to fix this in the version on NuGet so I can continue to use that one. I don't mind editing code but it would be nice if it worked out of the box.

Thanks for all your hard work on this, we've been using it for a while now, but in my opinion it's current state is worse than what it is a year ago.
I also don't understand the reason why you want to put LocTextUpper etc on obsolete. Using converters isn't always an option when you need multiple converters (and I don't like chaining converters).

There are also some data errors now:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.FrameworkElement', AncestorLevel='1''. BindingExpression:Path=Parent; DataItem=null; target element is 'ContextMenu' (Name='MainContextMenu'); target property is 'Parent' (type 'DependencyObject')

Closed Issue: Slow performance on Wrap Panel [9313]

$
0
0
Hello devs,

Currently I am working on a project that display a list of item inside wrappanel, and each item's template will contain a TextBlock which display the item's name and a text label with localization.

The problem is, the list_1 is 1000 items long, it take around 1 second for first load, which is fine, however, when I switch the warppanel to load the list_2 (1000 items long), it will take 2 second, and switch the warppanel to load back the list_1, it will take 5 seconds, and each time when I switch the ItemsSource, it will take longer time to load the list.

But for the same logic, without localization, the time for loading is constant (around 1 second) for loading the list, no matter how many times you switch the ItemsSource.

Does anyone has this problem before? Please help.. Thanks!

Sample project download link:
[http://www.verge.hk/temp/michael/localizeproject.zip](http://www.verge.hk/temp/michael/localizeproject.zip)

MainWindow.xaml
```
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Engine="clr-namespace:WPFLocalizeExtension.Engine;assembly=WPFLocalizeExtension"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="LocalizeProject.MainWindow"
lex:LocalizeDictionary.DesignCulture="en"
Title="MainWindow" Height="600" Width="800">
<Window.Resources>
<Style x:Key="ListViewItemStyle1" TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid Height="70" HorizontalAlignment="Left" Width="70">
<TextBlock HorizontalAlignment="Stretch" Margin="0,0,0,34" TextWrapping="Wrap" Text="{Binding ItemName}" Width="Auto" Height="Auto"/>
<Grid Height="34" VerticalAlignment="Bottom" Background="Red" Margin="4">
<TextBlock x:Name="SoldoutLabel" Margin="0,8" TextWrapping="Wrap" Text="{lex:LocText LocalizeProject:MultiLanguage:WPF_沽清}" Foreground="White"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<WrapPanel Orientation="Horizontal"
Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}" ScrollViewer.VerticalScrollBarVisibility="Disabled" d:DesignWidth="386" />
</ItemsPanelTemplate>
<Style x:Key="ListViewItemStyle2" TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid Height="70" HorizontalAlignment="Left" Width="70">
<TextBlock HorizontalAlignment="Stretch" Margin="0,0,0,34" TextWrapping="Wrap" Text="{Binding ItemName}" Width="Auto" Height="Auto"/>
<Grid Height="34" VerticalAlignment="Bottom" Background="Red" Margin="4">
<TextBlock Margin="0,8" TextWrapping="Wrap" Text="Soldout" Foreground="White"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate2">
<VirtualizingStackPanel IsItemsHost="True"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="DataTemplate1">
<Grid Height="20" HorizontalAlignment="Left" Width="20">
<TextBlock HorizontalAlignment="Stretch" Margin="0,0,0,5" TextWrapping="Wrap" Text="{Binding ItemName}" Width="Auto" Height="Auto"/>
<Grid Height="10" VerticalAlignment="Bottom" Background="Red" Margin="4">
<TextBlock Margin="0" TextWrapping="Wrap" Text="{lex:LocText LocalizeProject:MultiLanguage:a01}" Foreground="White"/>
</Grid>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid d:DataContext="{d:DesignData /SampleData/MainWindowViewModelSampleData.xaml}">
<ListView x:Name="ListViewLeft" HorizontalAlignment="Left" Margin="8,50,0,80" ItemsSource="{Binding AllItemMasterList}" Width="275" ItemContainerStyle="{DynamicResource ListViewItemStyle1}" ItemsPanel="{DynamicResource ItemsPanelTemplate1}">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
<ListView x:Name="ListViewRight" Margin="287,50,228,80" ItemsSource="{Binding AllItemMasterList_1}" ItemContainerStyle="{DynamicResource ListViewItemStyle2}" ItemsPanel="{DynamicResource ItemsPanelTemplate1}">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
<Button x:Name="LeftPageUpButton" Content="List 1" HorizontalAlignment="Left" Height="40" Margin="8,0,0,36" VerticalAlignment="Bottom" Width="105" Click="LeftPageUpButton_Click"/>
<Button x:Name="LeftPageDownButton" Content="List 2" HorizontalAlignment="Left" Height="40" Margin="117,0,0,36" VerticalAlignment="Bottom" Width="105" Click="LeftPageDownButton_Click"/>
<Button x:Name="RightPageUpButton" Content="List 1" Height="40" Margin="287,0,0,36" VerticalAlignment="Bottom" Click="RightPageUpButton_Click" HorizontalAlignment="Left" Width="105"/>
<Button x:Name="RightPageDownButton" Content="List 2" Height="40" Margin="0,0,283,36" VerticalAlignment="Bottom" Click="RightPageDownButton_Click" HorizontalAlignment="Right" Width="105"/>
<TextBlock HorizontalAlignment="Left" Height="38" Margin="8,8,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="214"><Run Language="zh-tw" Text="With Localization"/></TextBlock>
<TextBlock Height="38" Margin="287,8,283,0" TextWrapping="Wrap" VerticalAlignment="Top"><Run Language="zh-tw" Text="Without Localization"/></TextBlock>

</Grid>
</Window>
```

__Updates 31/01/2014:__
Moreover, the output windows will display the follow error whenever I feed a new list to the itemsource:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.FrameworkElement', AncestorLevel='1''. BindingExpression:Path=Parent; DataItem=null; target element is 'MainWindow' (Name=''); target property is 'Parent' (type 'DependencyObject')

Edited Issue: Slow performance on Wrap Panel [9313]

$
0
0
Hello devs,

Currently I am working on a project that display a list of item inside wrappanel, and each item's template will contain a TextBlock which display the item's name and a text label with localization.

The problem is, the list_1 is 1000 items long, it take around 1 second for first load, which is fine, however, when I switch the warppanel to load the list_2 (1000 items long), it will take 2 second, and switch the warppanel to load back the list_1, it will take 5 seconds, and each time when I switch the ItemsSource, it will take longer time to load the list.

But for the same logic, without localization, the time for loading is constant (around 1 second) for loading the list, no matter how many times you switch the ItemsSource.

Does anyone has this problem before? Please help.. Thanks!

Sample project download link:
[http://www.verge.hk/temp/michael/localizeproject.zip](http://www.verge.hk/temp/michael/localizeproject.zip)

MainWindow.xaml
```
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Engine="clr-namespace:WPFLocalizeExtension.Engine;assembly=WPFLocalizeExtension"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="LocalizeProject.MainWindow"
lex:LocalizeDictionary.DesignCulture="en"
Title="MainWindow" Height="600" Width="800">
<Window.Resources>
<Style x:Key="ListViewItemStyle1" TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid Height="70" HorizontalAlignment="Left" Width="70">
<TextBlock HorizontalAlignment="Stretch" Margin="0,0,0,34" TextWrapping="Wrap" Text="{Binding ItemName}" Width="Auto" Height="Auto"/>
<Grid Height="34" VerticalAlignment="Bottom" Background="Red" Margin="4">
<TextBlock x:Name="SoldoutLabel" Margin="0,8" TextWrapping="Wrap" Text="{lex:LocText LocalizeProject:MultiLanguage:WPF_沽清}" Foreground="White"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<WrapPanel Orientation="Horizontal"
Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}" ScrollViewer.VerticalScrollBarVisibility="Disabled" d:DesignWidth="386" />
</ItemsPanelTemplate>
<Style x:Key="ListViewItemStyle2" TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid Height="70" HorizontalAlignment="Left" Width="70">
<TextBlock HorizontalAlignment="Stretch" Margin="0,0,0,34" TextWrapping="Wrap" Text="{Binding ItemName}" Width="Auto" Height="Auto"/>
<Grid Height="34" VerticalAlignment="Bottom" Background="Red" Margin="4">
<TextBlock Margin="0,8" TextWrapping="Wrap" Text="Soldout" Foreground="White"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate2">
<VirtualizingStackPanel IsItemsHost="True"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="DataTemplate1">
<Grid Height="20" HorizontalAlignment="Left" Width="20">
<TextBlock HorizontalAlignment="Stretch" Margin="0,0,0,5" TextWrapping="Wrap" Text="{Binding ItemName}" Width="Auto" Height="Auto"/>
<Grid Height="10" VerticalAlignment="Bottom" Background="Red" Margin="4">
<TextBlock Margin="0" TextWrapping="Wrap" Text="{lex:LocText LocalizeProject:MultiLanguage:a01}" Foreground="White"/>
</Grid>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid d:DataContext="{d:DesignData /SampleData/MainWindowViewModelSampleData.xaml}">
<ListView x:Name="ListViewLeft" HorizontalAlignment="Left" Margin="8,50,0,80" ItemsSource="{Binding AllItemMasterList}" Width="275" ItemContainerStyle="{DynamicResource ListViewItemStyle1}" ItemsPanel="{DynamicResource ItemsPanelTemplate1}">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
<ListView x:Name="ListViewRight" Margin="287,50,228,80" ItemsSource="{Binding AllItemMasterList_1}" ItemContainerStyle="{DynamicResource ListViewItemStyle2}" ItemsPanel="{DynamicResource ItemsPanelTemplate1}">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
<Button x:Name="LeftPageUpButton" Content="List 1" HorizontalAlignment="Left" Height="40" Margin="8,0,0,36" VerticalAlignment="Bottom" Width="105" Click="LeftPageUpButton_Click"/>
<Button x:Name="LeftPageDownButton" Content="List 2" HorizontalAlignment="Left" Height="40" Margin="117,0,0,36" VerticalAlignment="Bottom" Width="105" Click="LeftPageDownButton_Click"/>
<Button x:Name="RightPageUpButton" Content="List 1" Height="40" Margin="287,0,0,36" VerticalAlignment="Bottom" Click="RightPageUpButton_Click" HorizontalAlignment="Left" Width="105"/>
<Button x:Name="RightPageDownButton" Content="List 2" Height="40" Margin="0,0,283,36" VerticalAlignment="Bottom" Click="RightPageDownButton_Click" HorizontalAlignment="Right" Width="105"/>
<TextBlock HorizontalAlignment="Left" Height="38" Margin="8,8,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="214"><Run Language="zh-tw" Text="With Localization"/></TextBlock>
<TextBlock Height="38" Margin="287,8,283,0" TextWrapping="Wrap" VerticalAlignment="Top"><Run Language="zh-tw" Text="Without Localization"/></TextBlock>

</Grid>
</Window>
```

__Updates 31/01/2014:__
Moreover, the output windows will display the follow error whenever I feed a new list to the itemsource:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.FrameworkElement', AncestorLevel='1''. BindingExpression:Path=Parent; DataItem=null; target element is 'MainWindow' (Name=''); target property is 'Parent' (type 'DependencyObject')

Edited Issue: Evaluate VS2013 Design-Time Behaviour [9312]

$
0
0
Evaluate VS2013 Design-Time Behaviour

Closed Issue: Evaluate VS2013 Design-Time Behaviour [9312]

$
0
0
Evaluate VS2013 Design-Time Behaviour

Closed Issue: "Key:" is returned when using empty key [9311]

$
0
0
Hi guys,

Thirst of all, I would like to thank you for your hard work on this great tool. I'm using it for some time in an application that I'm working on and it fulfilled all my requirements until now.
So, let's get to the subject:
I'm dynamically creating a toolbar for my application (VS2010 + WPF + PRISM + C#). For each toolbar button, the Content and the Tooltip are bounded to the VM properties using LocExtension/LocBinding objects. All the buttons have some content, so no problem in here, but only some of the buttons have a tooltip. For those that don't have a tooltip, the underlying VM property was returning an empty string and no tooltip was displayed at runtime when using version 2.1.3 of the localization library. Now I'm using the 2.2.0 version and there is a tooltip also for the buttons even that they shouldn't have one. It says just "Key:".

I made some quick investigations and I suspect that this is caused by the fix for issue #9291.
The __FormatOutput__ method in the __LocExtension__ class, just before returning, has this code:

```
if (targetType == typeof(String) || targetType == typeof(object))
result = "Key: " + key;
```

Do you think that's possible for you to update the above condition with an extra check for non-empty key values in a future version? Is there any other solution to accomplish my goal and I'm missing that?

Thanks in advance,
Bogdan

Edited Issue: "Key:" is returned when using empty key [9311]

$
0
0
Hi guys,

Thirst of all, I would like to thank you for your hard work on this great tool. I'm using it for some time in an application that I'm working on and it fulfilled all my requirements until now.
So, let's get to the subject:
I'm dynamically creating a toolbar for my application (VS2010 + WPF + PRISM + C#). For each toolbar button, the Content and the Tooltip are bounded to the VM properties using LocExtension/LocBinding objects. All the buttons have some content, so no problem in here, but only some of the buttons have a tooltip. For those that don't have a tooltip, the underlying VM property was returning an empty string and no tooltip was displayed at runtime when using version 2.1.3 of the localization library. Now I'm using the 2.2.0 version and there is a tooltip also for the buttons even that they shouldn't have one. It says just "Key:".

I made some quick investigations and I suspect that this is caused by the fix for issue #9291.
The __FormatOutput__ method in the __LocExtension__ class, just before returning, has this code:

```
if (targetType == typeof(String) || targetType == typeof(object))
result = "Key: " + key;
```

Do you think that's possible for you to update the above condition with an extra check for non-empty key values in a future version? Is there any other solution to accomplish my goal and I'm missing that?

Thanks in advance,
Bogdan

Closed Unassigned: Object of type 'SLLocalizeExtension.Extensions.LocTextExtension' cannot be converted to type 'System.String' [9292]

Edited Unassigned: Object of type 'SLLocalizeExtension.Extensions.LocTextExtension' cannot be converted to type 'System.String' [9292]

Viewing all 286 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>