How to get all of listBox marked checkBox? WPF
<p>XAML:</p>

<pre><code>&lt;Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApplication1"
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" x:Class="WpfApplication1.MainWindow"
    mc:Ignorable="d"
    Title="MainWindow" Height="637" Width="1889"&gt;
    &lt;Grid RenderTransformOrigin="0.505,0.844" Margin="0,0,0,19"&gt;
        &lt;CheckBox x:Name="cbFilter" Content="CheckBox" HorizontalAlignment="Left" Margin="15,410,0,0" VerticalAlignment="Top" Width="100" Height="25"/&gt;
        &lt;ComboBox x:Name="cbFilterMode" HorizontalAlignment="Left" Margin="95,410,0,0" VerticalAlignment="Top" Width="120"&gt;
            &lt;TextBlock&gt;=&lt;/TextBlock&gt;
            &lt;TabItem/&gt;
        &lt;/ComboBox&gt;
        &lt;TextBox x:Name="txtFilterValue" HorizontalAlignment="Left" Height="23" Margin="225,409,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/&gt;
        &lt;GroupBox x:Name="groupBox" Header="GroupBox" HorizontalAlignment="Left" Margin="225,10,0,0" VerticalAlignment="Top" Width="1110" Height="385"&gt;
             &lt;DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Margin="245,105,0,0" VerticalAlignment="Top" Height="230" Width="645"/&gt;
        &lt;/GroupBox&gt;
        &lt;ListBox x:Name="listBox"   HorizontalAlignment="Left" Height="385" Margin="10,10,0,0" VerticalAlignment="Top" Width="230" FontFamily="Segoe UI Black" Grid.Column="10"&gt;
            &lt;ListBox.ItemTemplate &gt;
                &lt;DataTemplate&gt;
                    &lt;CheckBox x:Name="qqq"  Content="{Binding }" IsChecked="{Binding IsChecked}" Click="CheckBox_Click"/&gt;
                &lt;/DataTemplate&gt;
            &lt;/ListBox.ItemTemplate&gt;
        &lt;/ListBox&gt;
&lt;/Grid&gt;
</code></pre>

<p>Code behind:</p>

<pre><code>private void CheckBox_Click(object sender, RoutedEventArgs e)
{

    var cb = sender as CheckBox;
    var item = cb.IsChecked;
    listBox.SelectedItem = item;

    if (listBox.SelectedIndex==0) return;



    string query = "SELECT NON EMPTY { [Measures].[Число Подписки] } ON COLUMNS, NON EMPTY {(";




    foreach (string i in listBox.Checked)
    {
        query += " " + i.ToString() + ".ALLMEMBERS *";
    }

    query = query.Remove(query.Length - 2);

    query += " )} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Почта] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS";
UpdateChart(query);

}
</code></pre>

<p>It turns out only to withdraw all at once, and how to do that would be deduced by one (ie. If <code>checkBox == true</code>, then we conclude that measurement of the cube)</p>