So as it turns out pretty much all the examples I have read online show no attributes when using the binaryMessageEncoder.

As it turns out, just like text encoding, you can add a readerQuotas element like this:

Someone by the name of Alpha wrote up a great article on how to accomplish this here:

http://wupeng.cn/post/2009/08/27/Add-Captcha-to-BlogEngineNet.aspx

There is, however one fix I had to do in order to make it work.

In the CommentView.aspx page (Step 2.2) for BE 1.6 this code does not work.  Instead you need to use this tag for the Input control (btnSaveAjax):

Thanks to Bryian Tan for posting this fix in the comments section of Alpha’s blog.

The UI for the converter kind of stinks right now because I have been concentrating on functionality.  I am now rendering XAML via plug-in modules.  In addition a preview of the rendered XAML is displayed after generating the XAML.

The UI is really basic right now:

image

Click the Load Mockup button to locate a .BMML mockup file.

image

The BMML document is parsed into a set of .NET objects.  For now, the controls are displayed in a grid.  This is going to be removed.  It was mainly used while coding the Mockup XML parsing logic.

image

Clicking generate will generate the XAML in the texbox at the bottom of the form.

image

In addition to generating the XAML, it is parsed at runtime and the Mockup is compiled at runtime and previewed.

image

That is the preview of the XAML rendered from my mockup below:

image

I still need to include the properties and sample data in the Xaml controls.  But for now, we have a start.

The following code creates a UriToBitmapImage value converter.  Simply reference the converter in your databinding and you will be able to data bind an Image control to a URL and have it displayed on your WPF surface.

First, the value converter code:

Add the value converter to your project and compile.

Next, you need to reference the namespace that contains this new class on the WPF Window/Page/Control that you wish to use the converter. (You can also add your converters at the App level.)

I added the UriToBitmapImageConverter class to the MyApp.Local namespace.  Thus, I needed to add a reference to the CLR namespace in my XAML in order to use the converter.

Next, you need to add the converter to your XAML page’s resources:

Here I used Page.Resources because I am adding this converter to a WPF Page.  It would be Window.Resources if you are working with a WPF Window or UserControl.Resources if you are adding this to a UserControl.

Now, simply data bind your image:

 

In the Source attribute I am data binding a URL / URI which is of type string.  This string is then passed through the UriToImageConverter and output is a BitmapImage object that downloads the image dynamically and displays it.

If I have some extra time, or requests, I will build a sample application to demonstrate.

Today the mockuptoxaml open source project officially kicked off.  The code and the project is not yet publicly published on Codeplex yet.  I am getting the code and the first alpha release of the application ready.  It is in its infancy.  I will post on my blog the progress of the application until it is officially available on codeplex.

Many thanks to Balsamiq for providing me with a license code free of charge.

So my baseline mockup looks like this:

image

Version 0.1 of the application 😀 generates this crude WPF form.  As you can see there is a lot of work to do, but it is slowly coming together.

image

This is a repost.  Someone named Tri Q in Syndey answered a question like this very elegantly.  I am reposting it in order to preserve it.

 

Here is the original question and answer.

You can do this without any code behind by using a IValueConverter.

[David Sandor]

I would take this a step further and modify the ItemTemplate

Here you have the converter class that you can re-use.

And finally, you need to declare your converter in a resource section.

Where Converters is the place you have placed the converter class. An example is:

The very nice thing about this approach is no repetition of code in your code behind.

In many cases you will need to set the visibility of a control based on a value of a property of your ViewModel class.  There are several ways to accomplish this.  The most reusable manner of accomplishing this is to use a value converter to convert the boolean value to a Visibility enumerator.  It sounds complicated but it is super easy.

Note: Before I continue I would like to state that this is an example simplified in order to describe this concept.  The code in this example databinds the IsChecked property of a CheckBox to the view model then databinds that boolean property to the Visibility property of the Button control.  In XAML you can property bind the two controls but that is not what this example is about.  Instead of making this a long example with database calls and other complications I wanted to make this as simple and clear cut as can be.  So if you are looking to databind the property of one control to the property of another this is not the right article for you.

image

So to demonstrate the value converter we will DataBind the (bool) IsChecked property of the CheckBox to the (bool) IsButtonVisible property of the MainWindowViewModel class.  The Visibility property of the Button control is databound to the same (bool) IsButtonVisible property of the MainWindowViewModel class.

So the XAML for this Window looks like this:

 

Note there is a Grid.Resources section in the XAML.  This section is making available to the controls on the Grid the BooleanVisibilityValueConverter object and is naming it BoolToVisible.  This will allow any control on this Grid to use that value converter.  In order to do this, I had to include a namespace that I called local in the Window tag declaration.  This sets up a reference to the Namespace where the Value Converter class resides.

Next, in the Button control’s XAML you see that the Visibility Property is DataBound to the IsButtonVisible property of the DataContext.  Below is the code behind for this Window:

And the code for the MainWindowViewModel is located below:

As you can see the IsButtonVisible property which both the CheckBox and Button are databound is a boolean.  This is possible via the ValueConverter:

This value converter code will accept a Boolean value in, and spit out a Visibility enum.  The magic happens in this databinding expression for the button control’s visibility property:

Here we are setting the binding to the IsButtonVisible property of the DataContext.  In addition we are telling the DataBinder to use the converter named BoolToVisible.  Remember we gave our BooleanVisibilityValueConverter class a key name of BoolToVisible when we defined the Grid Resources.

Attached is a sample project.  I hope this helps someone!

Download Source Code: ValueConverterExample.zip