Reputation: 275
I have created a custom activity that has Arguments that are created at design time, and I am having an issue associating them with an ExpressionTextBox in the designer.
The ExpressionTextBox shows in the designer, and they reflect the value of the Argument it is bound to, however entering an expression in the ExpressionTextBox does not get routed back to the argument. Examples / code is in order.
It wont let me post images, so a link will have to do. Designer Example
In the image above I entered in 'param2' in the second ETB then clicked the 'Edit Arguments' button. (The Edit Arguments button shows a DynamicArgumentDialog). If i enter in a value in the DyanmicArgumentDialog however that does show up on the designer when I click OK.
Here is the xaml for my designer (I'm probably missing something)
<ItemsControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding ModelItem.Arguments}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70" SharedSizeGroup="nameColumn" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<sapv:ExpressionTextBox Grid.Column="1"
Expression="{Binding Path=., Mode=TwoWay, Converter={StaticResource expressionConverter}, ConverterParameter=Out}"
OwnerActivity="{Binding DataContext.ModelItem, ElementName=layoutRoot}"
ExpressionType="s:String"
UseLocationExpression="True"
MaxLines="1"
AcceptsReturn="False" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
(layoutRoot is the name of the root element of my designer, so that I can get access to the ModelItem from inside of the ItemTemplate) (the Arguments property on my Activity is defined as Collection and currently has two items in the list)
Although I could just use the DynamicArgumentDialog to set my arguments, I would love to get them showing in the designer. Can anyone see anything wrong with this, and maybe why it isn't working?
I also have a sample if anyone wants to take a look at it. DynamicArgumentTest
Has anyone had any luck in getting ExpressionTextBoxes working properly with dynamic arguments?
Upvotes: 2
Views: 1425
Reputation: 1265
Set binding in code
var bind = new Binding();
bind.Mode = BindingMode.TwoWay;
bind.Converter = new ArgumentToExpressionConverter();
bind.ConverterParameter = direction;
bind.Path = new PropertyPath(
String.Format("ModelItem.Arguments[{0}]", argumentName));
//Out arguments require L-Value expression
if (direction == "out")
expressionTbx.UseLocationExpression = true;
//Set the binding and Add the expression block to the grid
expressionTbx.SetBinding(ExpressionTextBox.ExpressionProperty, bind);
Upvotes: 0