Thursday, 23 October 2014

ComboBox binding in Workflow activities

Today I was creating a simple activity with a couple of combo boxes, and came across a problem where the binding wasn’t working correctly (well, at all). I had an InArgument<string> property on my activity, and wanted to set this from a combo box on the design surface. I guess I haven’t done this before as it doesn’t work out of the box, and you need to write an IValueConverter to get it working. I’ve trodden this path before but this was a bit of a tricky beast.

After some wailing and gnashing I came up with the following base class converter…

public abstract class ComboBoxToModelItemConverter<T> : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
T retVal = default(T);

ModelItem mi = value as ModelItem;

if (null != mi)
var arg = mi.GetCurrentValue() as InArgument<T>;

if (null != arg)
var expression = arg.Expression;
var literal = expression as Literal<T>;

if (null != literal)
retVal = literal.Value;

return retVal;

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
return new InArgument<T>((T)value);

I then created a concrete class to bind to InArgument<string>…

public class ComboBoxStringToModelItemConverter : ComboBoxToModelItemConverter<string>

With that created I could then get the binding to work by adding the converter to the binding. I have a class that contains TemplateId and Name, I wish to show the Name on screen but store the TemplateId (and this is mapped to an InArgument<string> on the activity). The XAML is as follows…

<local:ComboBoxStringToModelItemConverter x:Key="comboConverter"/>

<ComboBox ItemsSource="{Binding Templates}" 
SelectedValue="{Binding ModelItem.TemplateId, Converter={StaticResource comboConverter}}"
="TemplateId" DisplayMemberPath="Name" />

With that done it all works as expected. I’m surprised that a converter such as this doesn’t exist in the Workflow libraries – and also in the many, many years I’ve been playing with Workflow that I’ve not needed one. Anyhow, I hope this is of use to someone!


Tech IT Solutions said...

Oh so you finally created the Base Class convertor in order to do the binding task in combo box.You have intelligently found out the way out.

custom writing service reviews said...

Wow looks pretty complex as well as amazing for a amateur like me, great post! Hope to see more of your work soon, you seem like a very talented programmer.

Oliver Maurice said...

Visit this awesome blog for some information on how to write a great research paper. I think that you will find lots of interesting info there

AngelaHolt said...

Thanks for sharing the information. Keep the good work going. Root explorer Viper4android youtubevanced

Robert B said...

Nice sharing amazing one keep sharing more thanks for all lovely one avian vet long island

meldaresearch said...

Students should ensure that quality of essays offered match their prices. All our Nursing Research Paper Writing Service should ensure that customers’ private details are kept in privacy. This also applies when one need to seek for write my term paper online.

Assignment Help said...

Thank for sharing this information. We provide writing help services at Australi. Hire Now!
Taxation Law Assignment Help

KeiraDoltan said...

Nice blog, The future of the students depends on the grades they obtain in their academic studies. High grades for better job opportunities.
Assignment Provider
All Assignment Help

meldaresearch said...

Our Research Writing Services is normally written by professionals who have sufficient experience in writing academic papers in any discipline. Our customer service is available 24/7, which makes it easy for clients to place orders and receive their Help in Essay Writing on time.

William Shell said...

Hey, Your blog is very informative. It is nice to read such high-quality content. Attractive information on your blog, thank you for taking the time and share with us.Myassignmenthelp delivers high-quality content related to science assignment help writing services.

Puremelda said...

You have all the reasons not to trust cheap paper writing services, Custom Writing Writers, and dissertation writing help. We offer the Write an Essay for Me to the clients at an affordable price.

Ethan Lee said...

We all are aware of the fact that it is too tough for anyone to write their, assignment, essay, thesis, dissertation or paper, also, there are lots of students who in search of good marks in their academics, search GOOGLE for Perdisco, Assignment Help, Essay Help, Thesis Help, Paper Help, Research Paper Help or Dissertation Editor, How to Write a Bibliography. But the problem is that these services are not pocket-friendly for every student.
So, What is the Solution?
You can use Paraphrasing Generator Tool, with the help of this tool, rewriting an article, essay or assignment is a work of just a few clicks, Also, we know the importance of Plagiarism Free work, that's why we developed our online paraphrasing tool in such a way that their will be no chance of plagiarism.

Unknown said...

I am very happy to visit your blog and read this article. This is the kind of information that needs to be given and not the random misinformation that’s at the other blogs. I appreciate your post. write my paper

Unknown said...

It’s good to know about your blog and its post. You have done pretty impressive work on this blog and it posts, Keep up doing well. affordable papers

Robert B said...

I read your blog post and this is nice blog post.. thanks for taking the time to share with us. have a nice day Network

norhan said...

مكافحة حشرات بالخبر افضل شركة مكافحة حشرات بالخبر
مكافحة حشرات بمكة افضل شركة رش حشرات بمكة
مكافحة حشرات بالمدينة المنورة افضل شركة رش حشرات بالمدينة المنورة
مكافحة حشرات بالدمام افضل شركة مكافحة حشرات بالدمام

Florahmelda said...

Our Professional Medicine Essay Writers work tirelessly to ensure that your Medicine Research Paper Writing is completed within the time frame given to avoid poor scores in your Medical Essay Assignments Writing.

ahmed5987 said...

يمكن أن تسبب المزاريب المسدودة أضرارًا في الرطوبة للأفاريز والأسطح وحتى تسبب تسربًا داخليًا. أفضل وقت لتنظيف المزاريب هو بعد سقوط كل الأوراق في الخريف. لسوء الحظ ، إذا كان لديك الكثير من أشجار الصنوبر والأشجار دائمة الخضرة ، فإنها تميل إلى التخلص من الإبر على مدار السنة وقد تضطر إلى تنظيف المزاريب في كثير من الأحيان أو تثبيت حراس المزراب التي تشوه الحطام.
شركة تنظيف بالدمام
شركة تنظيف بالاحساء
شركة كشف تسربات المياه بالاحساء

Pinoy Swertres said...

Enjoy your famous family web blog please bookmarks pinoy Channel to watch abs-cbn and gma shows.

Sam said...

Assignment help Australia offers custom and professional assignment writing help to both college and university students who are stuck with their research projects, essays, case studies, business reports and need Urgent Assignment Help.

noor said...

ارخص شركة نقل عفش

ارخص شركة نقل عفش بالمدينة المنورة نقل عفش بالمدينة المنورة
ارخص شركة نقل عفش بمكة نقل عفش بمكة
شركة نقل عفش شركة نقل عفش

ارخص شركة نقل عفش بجدة نقل عفش بجدة
دينا نقل عفش جدة دينا نقل عفش بجدة

Anonymous said...

If you are someone who is looking to deal with stress without leaving your desk then play rummy online is one of the best stress-busters you could possibly come by. According to recent demography, people of all age groups are attracted to the game which is evidenced by the increasing traffic to various rummy sites. Do you have any queries in your mind regarding how to play rummy? Then have a word with our team right now, call us. Hence, do not hesitate to connect us whenever you need help.

Term Paper Writing Services said...

Professional History Research Paper Services is very popular for students in search for history essay writing help services and history assignment writing services

Katie Talbot said...

Despite so many great points, students seek for Industrial industrial relations assignment help. Industrial relations teach to protect the rights of managers along with other resources. One of its aims is to protect the rights and interests of the workers to enhance their economic conditions. These mechatronics assignment help hold a lot of importance since they possess the capabilities to balance out the lower scores of theory examinations. Here are a few more points that can convince you to submit all the assignments by the due date. psychology assignment help are an alternative to brush up the grades. If you are weak at theoretical examinations, then tasks can do the job for you.

invincible01 said...

Amazing Article, Really useful information to all So, I hope you will share more information to be check and share here.

inplant training
inplant training chennai
inplant training in chennai
inplant training at chennai
inplant training
inplant training chennai
inplant training in chennai
inplant training at chennai
inplant training
Inplant Training for cse

Great Assignment Help said...

Students who have issues with their paper can rapidly associate with the right Paper help online service so you can get the suitable paper help. said...

I would like to be your pen friend...You can write me email on for
Jaipur Escort
Jaipur Escort
Jaipur Escort
Delhi Escort
Guwahati Escort
Guwahati Escort
Guwahati Escort
Guwahati Escort
Lucknow Escort
Aerocity Escort

Bunny .cow said...

ปล่อยใจสนุกสุดมันส์ไปกับ Sagaming ผู้ให้บริการบาคาร่าออนไลน์สุดทันสมัยและครบวงจร บริการครบจบในเว็บเดียว มีรูปแบบการเล่นที่หลากหลาย และห้องเดิมพันสุดพิเศษ VIP ให้เลือกเล่นมากกว่า 20 ห้อง เล่นง่าย ได้เงินจริง และจ่ายเงินไวใน 1 นาที และมีโปรโมชั่นต้อนรับสมาชิกใหม่ และโปรโมชั่นเอาใจสมาชิกเก่าอีกมากมาย แจกหนักกจัดเต็มไม่ยั้ง และจัดกิจกรรมดี ๆ ให้ผู้เล่นได้ร่วมสนุกลุ้นรับของรางวัลอื่น ๆ อีกเพียบ อัพเดตกิจกรรมทุกเดือน และมีโปรโมชั่นบาคาร่าสุดคุ้มแจกฟรีตลอดทั้งปี และยังมีระบบฝากถอนที่ปลอดภัยอีกด้วย ฝากง่าย ถอนเงินไว ด้วยแอพพลิเคชั่น True Money Wallet ฟรี ไม่มีค่าบริการ และสามารถทำรายการด้วยตนเองง่าย ๆ ไม่ต้องผ่านแอดมินอีกต่อไป