0
我正在嘗試製作一個活動設計器庫。我有兩個來源;其中一個是C#代碼中的CodeActivity
,另一個是XAML中的Activity設計器。在CodeActivity
,我有一個公共財產Name
。在XAML中,我想通過綁定來查看和更改它的值。 My XAML design is like this如何將表單代碼活動綁定到XAML?
我宣佈Name
屬性是這樣的:
private string _name;
public string Name {
get { return _name; }
set
{
_name = value;
NotifyPropertyChanged("Name");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}
我的XAML是這樣的:
...
<DataTemplate x:Key="Expanded">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="130"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="txtName" Grid.Column="1" Grid.Row="0" Text="{Binding Name, Mode=TwoWay}"/>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Name :" HorizontalAlignment="Right"/>
</Grid>
<sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Body, Mode=TwoWay}"
HintText="Please drop an activity here" />
</StackPanel>
</DataTemplate>
我已經嘗試了很多辦法,但我不能這樣做。 如何在XAML中顯示CodeActivity
中的Name
屬性?
能否請您給我們更多的XAML的? –