在我的基类中,我具有以下内容:
private string groupOperator;
public string GroupOperator
{
get
{
this.groupOperator = ConvertOperatorToString();
return this.groupOperator;
}
set
{
this.groupOperator = value;
OnPropertyChanged("GroupOperator");
}
}
private bool isOrOperator = false;
public bool IsOrOperator
{
get
{
return this.isOrOperator;
}
set
{
this.isOrOperator = value;
OnPropertyChanged("IsOrOperator");
}
}
public string ConvertOperatorToString()
{
if (IsOrOperator)
{
return "Or";
}
else
{
return "And";
}
}
我正在使用TextBlock在我的XAML中显示GroupOperator。理想的功能是根据“切换按钮”是否在“ /”和“ /”之间更改字符串值。现在,它根本没有改变TextBlock,我想知道我做错了什么。
这是我的XAML:
<TextBlock Style="{StaticResource TextBlockBaseStyling}" VerticalAlignment="Center" Text="{Binding GroupOperator, UpdateSourceTrigger=PropertyChanged}"/>
<ToggleButton x:Name="OperatorSwitch" Style="{StaticResource ToggleViewSwitch}"
Visibility="{Binding IsToggleVisible, UpdateSourceTrigger=PropertyChanged}"
IsChecked="{Binding IsOrOperator, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
</Grid>
</Grid>
<ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1"/>
</Grid>
</Border>
</Grid>
</StackPanel>
注意:正确处理PropertyChange时,ParentGroup.GroupOperator和GroupOperator实际上应该是相同的值。
相关分类