BooleanToVisibilityConverter无法正常工作

时间:2013-06-16 16:04:55

标签: wpf xaml controls visibility wpftoolkit

在我正在开发的图表应用程序中,我无法隐藏我的系列。我试图将可见性绑定到我的单选按钮IsChecked属性。图表来自WPF Toolkit。这是代码:

<RadioButton GroupName="ChartSeries" Name="areaRadioButton" Content="Area Series" Margin="10,10,0,0" IsChecked="False"/>
<RadioButton GroupName="ChartSeries" Name="barRadioButton" Content="Bar Series" Margin="10,30,0,0" IsChecked="False"/>
<RadioButton GroupName="ChartSeries" Name="bubbleRadioButton" Content="Bubble Series" Margin="10,50,0,0" IsChecked="False"/>
<RadioButton GroupName="ChartSeries" Name="columnRadioButton" Content="Column Series" Margin="10,70,0,0" IsChecked="False"/>
<RadioButton GroupName="ChartSeries" Name="lineRadioButton" Content="Line Series" Margin="105,10,0,0" IsChecked="False"/>
<RadioButton GroupName="ChartSeries" Name="pieRadioButton" Content="Pie Series" Margin="105,30,0,0" IsChecked="False"/>

<chart:Chart Name="chart1">
       <chart:Chart.Series>
             <chart:ColumnSeries Visibility="{Binding IsChecked, ElementName=columnRadioButton,Converter={StaticResource booleanToVisibility}}" ItemsSource="{Binding ChartItems}" IndependentValueBinding="{Binding Path=Name}" DependentValueBinding="{Binding Path=Value}"/>
             <chart:PieSeries Visibility="{Binding IsChecked, ElementName=pieRadioButton, Converter={StaticResource booleanToVisibility}}" ItemsSource="{Binding ChartItems}" IndependentValueBinding="{Binding Path=Name}" DependentValueBinding="{Binding Path=Value}"/>
       </chart:Chart.Series>
</chart:Chart>

我已将我的boolean to visibility转换为如下声明:

<Window.Resources>
    <BooleanToVisibilityConverter x:Key="booleanToVisibility" />
</Window.Resources>

提前谢谢你。

0 个答案:

没有答案