WPF: ObjectDataProvider and the System.Windows.TextAlignment Enum

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I need to use an ObjectDataProvider in a resource file to pull in the
System.Window.TextAlignment enum which is part of the PresentationCore.DLL.

I was able to do this with the HorizontalAlignment enum which uses the
PresentationCore.DLL like this:


xmlns:sysWin="clr-namespace:System.Windows;assembly=PresentationFramework"

<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}"
x:Key="resHorizontalAlignment">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sysWin:HorizontalAlignment"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>



But for 'TextAlignment ', this does NOT work:

xmlns:sysWinCore="clr-namespace:System.Windows.Interop;assembly=PresentationCore"

<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}"
x:Key="resTextAlignment">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sysWinCore:TextAlignment"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

I get the compile error:
Error 101 Type 'TextAlignment' was not found.

Any advice:

Thanks
 
moondaddy said:
I need to use an ObjectDataProvider in a resource file to pull in the
System.Window.TextAlignment enum which is part of the PresentationCore.DLL.

I was able to do this with the HorizontalAlignment enum which uses the
PresentationCore.DLL like this:


xmlns:sysWin="clr-namespace:System.Windows;assembly=PresentationFramework"

<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}"
x:Key="resHorizontalAlignment">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sysWin:HorizontalAlignment"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>



But for 'TextAlignment ', this does NOT work:

xmlns:sysWinCore="clr-namespace:System.Windows.Interop;assembly=PresentationCore"

<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}"
x:Key="resTextAlignment">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sysWinCore:TextAlignment"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

I get the compile error:
Error 101 Type 'TextAlignment' was not found.

Any advice:

Try
xmlns:sysWinCore="clr-namespace:System.Windows;assembly=PresentationCore"
(I think it's the ".Interop" in your version that's causing the problem).

Chris Jobson
 
Back
Top