将标题绑定到选定的组合框文本

时间:2013-04-10 13:26:54

标签: c# wpf combobox charts

如何将图表的标题绑定到ComboBox中选择的文字?

这是我的代码:

XAML

<DVC:Chart.Axes>
    <DVC:LinearAxis Orientation="Y" Title="Ammount of calls" ShowGridLines="True" Interval="auto"/>
    <DVC:LinearAxis Orientation="X" Title="{Binding Path=combobox1}" ShowGridLines="True" Interval="1"/>
</DVC:Chart.Axes>

正如您所看到的那样,我试图将ComboBox1 x-axis绑定到<ComboBox x:Name="combobox1" HorizontalAlignment="Left" Margin="16,90,0,0" VerticalAlignment="Top" Width="120" SelectionChanged="combobox1_SelectionChanged"> <ComboBoxItem Content="Graph per Hour"/> <ComboBoxItem Content="Graph per Minute"/> </ComboBox>

{{1}}

以上是ComboBox。提前谢谢。

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

Title="{Binding SelectedItem.Content, ElementName=combobox1}"
相关问题