Answered by:
Cannot declare the resource key for the Converter in generic.xaml?

Question
-
Hi Guys,
I am not able declare the Resource key for the Converter in the generic.xaml file. It throws an exception like " Could not find %0 from the text %1". But i can do this in the Metro style application instead of class library. Does it mean Converter is restricted in generic.xaml ?. Or Am i wrong ?
Regards,
David CThursday, October 6, 2011 12:43 PM
Answers
-
Ok now I see. You are getting an error about the type not found. Yes right now the XamlMetaData is not being generated for types in resource dictionaries like that. I think we already have this solved, but I will be logging a bug regardless just to make sure :-)
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)- Marked as answer by David alice DD Friday, October 7, 2011 8:31 AM
Friday, October 7, 2011 7:33 AM
All replies
-
Can you post your usage?
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)Friday, October 7, 2011 4:10 AM -
Hi Tim,
<ResourceDictionary 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:this="using:TestingDemo"><this:TextConverter x:Key="conv" />
<Style TargetType="this:Testing">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="this:Testing">
<Grid>
<Border />
<TextBlock x:Name="txt" Text="{Binding Path=Content,Converter={StaticResource conv}}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>When i use this lines in my custom control. It throws an exception.
Regards,
David C
Friday, October 7, 2011 5:17 AM -
This is helpful. Can you share the converter source (or perhaps a smaller repro)? I'll log a bug for investigation once we have that.
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)- Proposed as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Tuesday, October 11, 2011 11:51 PM
Friday, October 7, 2011 6:28 AM -
Hi Tim,
I have attached my sample in the following link. I am waiting for your answer.
https://skydrive.live.com/?cid=15a7af5367540026&sc=documents&nl=1&uc=1&id=15A7AF5367540026%21172#
Regards,
David C
Friday, October 7, 2011 7:19 AM -
Ok now I see. You are getting an error about the type not found. Yes right now the XamlMetaData is not being generated for types in resource dictionaries like that. I think we already have this solved, but I will be logging a bug regardless just to make sure :-)
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)- Marked as answer by David alice DD Friday, October 7, 2011 8:31 AM
Friday, October 7, 2011 7:33 AM -
Ok thanks Tim.
Regards,
David CFriday, October 7, 2011 8:31 AM -
I have the same error in the Consumer Preview. Here is my code:
class Cls { public Cls(){} }
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:TestApplication"> <local:Cls x:Key="resourceCls"> </local:Cls> </ResourceDictionary>
<Page.Resources> <ResourceDictionary Source="Dictionary1.xaml"/> </Page.Resources>
Thursday, April 5, 2012 1:38 PM -
@Sergey make your class public
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)Thursday, April 5, 2012 3:36 PM -
Tim, this didn't help.Friday, April 6, 2012 6:50 AM
-
it seems to work for me. here is what I tried
<Page
x:Class="Application3.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Application3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary Source="Dictionary1.xaml"/>
</Page.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
<TextBlock DataContext="{Binding Source={StaticResource myClass}}" Text="{Binding DisplayValue}"/>
</Grid>
</Page><ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Application3">
<local:MyClass x:Key="myClass"/>
</ResourceDictionary>public class MyClass
{
public string DisplayValue { get; set; }
public MyClass()
{
DisplayValue = "this is some text and more text";
}
}
http://leeontech.wordpress.com/
- Edited by lee d Friday, April 6, 2012 11:00 AM
Friday, April 6, 2012 11:00 AM -
Changing property of "Dictionary1.xaml" Build Action to "Page" solve this problem. This is very strange because other properties of resource files setted to "content".Friday, April 6, 2012 3:28 PM
-
@Sergey - ah were you working on an older project from Dev Preview? All resource dictionary files now added/created to the project are marked as Page. This is required to get XAML validation and code generation for any custom types used within those resource dictionaries.
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)Friday, April 6, 2012 3:37 PM -
Yes, you are right. This project was created in Dev Preview.Monday, April 9, 2012 5:08 AM
-
Hi Tim,
Is this bug fix released?
Thanks
Wednesday, May 23, 2012 12:36 PM -
@Anatoli - ensure that your dictionary is marked as page is the fix. This should already be the case when new projects/items are created in the consumer preview.
Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
(if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)Wednesday, May 23, 2012 2:24 PM -
Can you please leaborate on "the XamlMetaData is not being generated for types in resource dictionaries"? What exactly does it mean?
Mikhail
Thursday, July 5, 2012 11:58 AM