Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

Commented Issue: Can't get MessageBinder.SpecialValues to work in Windows 8 app [264]

$
0
0
I'm brand new to Caliburn.Micro, so I'm hoping somebody might be able to help me here :). Apologies, posted this first to StackOverflow before I saw this Issue Tracker: http://stackoverflow.com/questions/13732657/using-messagebinder-specialvalues-in-windows-8-app-not-working

I'm trying to use MessageBinder.SpecialValues in my Windows 8 app, but I can't get it to work. I'm adding a new "$pointerPercentage" to know the percentage (float between 0.0 and 1.0) of how far the mouse is positioned within an element (for a music keyboard in my synthesizer app). Everything else is currently working (so I believe I have Caliburn.Micro wired up properly).

I've added the following to the Configure method of my App.xaml.cs:

protected override void Configure()
{
container = new WinRTContainer();
container.RegisterWinRTServices();

MessageBinder.SpecialValues.Add("$pointerPercentage", ctx =>
{
return 1.0f;
});
}

Then I'm using it from a PointerMoved event within a Canvas element:

<Canvas x:Name="keyCanvas" Background="#338B8BDC"
cal:Message.Attach="[Event PointerMoved] = [Action UpdateKeyboard($pointerPercentage)]" />

The UpdateKeyboard method in my ViewModel does get fired (I break into it with a debugger), but the parameter passed in is always 0.0f (not 1.0f as set in the SpecialValues code above).

What am I doing wrong? Any help would be appreciated :).
Comments: I've added the answer on StackOverflow, but the problem is that you have your SpecialValues key with an uppercase P (pointerPercentage) CM converts the action message params to lowercase when comparing to your list of SpecialValues, but it doesn't convert the SpecialValues.Key value to lowercase when doing this. Change your pointerPercentage to pointerpercentage and it should work Question is - is this by design or should CM also be converting to lowercase when comparing keys (or possibly just when adding keys to the dictionary) to prevent this from happening

Viewing all articles
Browse latest Browse all 1760

Trending Articles



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