WPF and X# 2.0.0.05

This forum is meant for questions and discussions about the X# language and tools
Post Reply
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

WPF and X# 2.0.0.05

Post by George »

Hi,

one of my WinForm Apps uses WPF Bing Maps V.7 (I wrote a WPF DLL containing the Bing Maps control).

Inside this WPF DLL assembly, one of the components I am using is an 'Infobox' Grid consisted by:
- InfoboxTitle (TextBlock)
- InfoboxDescription (TextBlock)
- CloseInfobox (Button)

some years ago, when I created the assembly, I set the Infobox Background="Black" and the InfoboxTitle and InfoboxDescription Foreground="#1cff1c" ('electric' Green).

Now, I am trying to change the Background and Foreground from my App by changing the 2 Properties sending values to the WPF assembly.

I noticed 2 errors:

1. The compiler conplains at:
PUBLIC CLASS MainVM IMPLEMENTS INotifyPropertyChanged
this Class is used to change the 2 Properties.

By the way, the ILSpy (XSharp) code shows:
public class MainVM implement INotifyPropertyChanged (not implements)
when translates my C# project to X#.

2. The compiler conplains Inside the .XAML at keyword: local:
<Window.DataContext>
<local:MainVM/>
</Window.DataContext>
i.e. when I try to reference this Class inside the .XAML code in order to use it the 2 Properties.

I am attaching 2 projects:

A> a C# named Wpf_PropertyChanged:
it works just fine and I can see the Background, Foreground color changes in XAML Editor.
The problem is I cannot use it because my WPF assembly is Vulcan.NET (X# now) is big (has many components) and I don't want to translate it to C#.

B> a X# named Wpf_XS:
here you can see the 2 errors

Both .XAML files (C# and X#) contain the SAME code.
In the C# one, I have as comments the old: Background="Black", Foreground="#1cff1c"
but in the X#, I have as comments the new (desired) code: Background="{Binding Path=BackgroundColor}", Foreground="{Binding Path=ForegroundColor}".

I know there are experts on WPF in this Group (Nick, Dick, Wolfgang, Philip etc.).

Could you please tell me if the 2 previously mentioned problems are mine errors, or really errors ?

thanks and regards
George
Attachments
Wpf_XS.zip
(9.75 KiB) Downloaded 23 times
Wpf_PropertyChanged.zip
(15.46 KiB) Downloaded 21 times
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

WPF and X# 2.0.0.05

Post by Chris »

Hi George,

About the compiler error, this is due to a typo in the code, the event name should be named "PropertyChanged", not "eventPropertyChanged". After you change this, it will compile fine.

About the other issue with the XAML, unfortunately I have no experience in this area to tell, maybe someone else can give some insight. It does appear to be a problem with x# though, since similar XAML works without errors in c#, so I will log this as a bug.

Chrs
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
NickFriend
Posts: 248
Joined: Fri Oct 14, 2016 7:09 am

WPF and X# 2.0.0.05

Post by NickFriend »

I had a look at the C# and xaml and that seems fine... afraid I haven't actually got X# installed at the moment, but it ought to work I think (especially as George says it works ok in C#).

Nick
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

WPF and X# 2.0.0.05

Post by robert »

George,
Your local definition in the XAML is
xmlns:local="clr-namespace:Wpf_PropertyChanged"

but the namespace in which the class is defined is Wpf_XS
Change the local to

xmlns:local="clr-namespace:Wpf_XS"

and it works as expected

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

WPF and X# 2.0.0.05

Post by George »

Thank you Chris, Nick, Robert.

The worst mistakes are the 'copy/paste' ones!

Yes it works now.

Chris, you have to remove the ticket/log for the XAML.

regards
George
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

WPF and X# 2.0.0.05

Post by Chris »

George wrote: Chris, you have to remove the ticket/log for the XAML.
I had not logged it yet, waited a little more, just in case somebody spotted an error in the code :)
So thanks to Robert for that, and also to Nick for stepping in to help!
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply