Dispatcher.Invoke((System.Windows.Forms.MethodInvoker)delegate
{
UI.UI_ControlViewer.UI_Viewer.UI_Report.AddLog((sender as Libraries.Events).Value, e.PropertyName);
});
System.InvalidOperationException: "Вызывающий поток не может получить доступ к данному объекту, так как владельцем этого объекта является другой поток."
<ItemsControl ItemsSource="{Binding Channels}" Grid.Row="1"/>
<DataTemplate DataType="{x:Type control:ControlPanel}">
<DataTemplate.Resources>
<local:IntToBooleanConverter x:Key="IntToBoolConverter" />
</DataTemplate.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="34" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<RadioButton
Name="ChannelButton_1"
Grid.Column="0"
Content="1"
IsChecked="{Binding Channel, Converter={StaticResource IntToBoolConverter}, ConverterParameter=0}" />
<RadioButton
Name="ChannelButton_2"
Grid.Column="1"
Content="2"
IsChecked="{Binding Channel, Converter={StaticResource IntToBoolConverter}, ConverterParameter=1}" />
<RadioButton
Name="ChannelButton_3"
Grid.Column="2"
Content="3"
IsChecked="{Binding Channel, Converter={StaticResource IntToBoolConverter}, ConverterParameter=2}" />
<RadioButton
Name="ChannelButton_4"
Grid.Column="3"
Content="4"
IsChecked="{Binding Channel, Converter={StaticResource IntToBoolConverter}, ConverterParameter=3}" />
</Grid>
<ContentControl
Name="Channel_1"
Grid.Row="1"
Content="{Binding Channels[0]}" />
<ContentControl
Name="Channel_2"
Grid.Row="1"
Content="{Binding Channels[1]}" />
<ContentControl
Name="Channel_3"
Grid.Row="1"
Content="{Binding Channels[2]}" />
<ContentControl
Name="Channel_4"
Grid.Row="1"
Content="{Binding Channels[3]}" />
</Grid>
<DataTemplate.Triggers>
<Trigger SourceName="ChannelButton_1" Property="IsChecked" Value="True">
<Setter TargetName="Channel_1" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger SourceName="ChannelButton_1" Property="IsChecked" Value="False">
<Setter TargetName="Channel_1" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="ChannelButton_2" Property="IsChecked" Value="True">
<Setter TargetName="Channel_2" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger SourceName="ChannelButton_2" Property="IsChecked" Value="False">
<Setter TargetName="Channel_2" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="ChannelButton_3" Property="IsChecked" Value="True">
<Setter TargetName="Channel_3" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger SourceName="ChannelButton_3" Property="IsChecked" Value="False">
<Setter TargetName="Channel_3" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="ChannelButton_4" Property="IsChecked" Value="True">
<Setter TargetName="Channel_4" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger SourceName="ChannelButton_4" Property="IsChecked" Value="False">
<Setter TargetName="Channel_4" Property="Visibility" Value="Collapsed" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate x:Key="SelectContext" DataType="{x:Type converters:Item}">
<DataTemplate.Resources>
<converters:IntToBooleanConverter x:Key="IntToBoolConverter"/>
</DataTemplate.Resources>
<Border x:Name="Data"
Height="40">
<Grid x:Name="ContentBase"
Margin="1,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Name="DisplayText"
Grid.Column="0"
Margin="0"
Padding="0"
HorizontalAlignment="Left"
Content="{Binding Name}"
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=Self}}"/>
<RadioButton Name="_1"
Grid.Column="1"
Content="1"
IsChecked="{Binding ItemMode, Converter={StaticResource IntToBoolConverter}, ConverterParameter=1}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=Self}}"
Style="{StaticResource RadioButtonKeys}"/>
<RadioButton Name="_2"
Grid.Column="2"
Content="2"
IsChecked="{Binding ItemMode, Converter={StaticResource IntToBoolConverter}, ConverterParameter=2}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=Self}}"
Style="{StaticResource RadioButtonKeys}"/>
<RadioButton Name="_3"
Grid.Column="3"
Content="3"
IsChecked="{Binding ItemMode, Converter={StaticResource IntToBoolConverter}, ConverterParameter=3}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=Self}}"
Style="{StaticResource RadioButtonKeys}"/>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="ContentContext" DataType="{x:Type converters:Item}">
<DataTemplate.Resources>
<converters:IntToBooleanConverter x:Key="IntToBoolConverter"/>
</DataTemplate.Resources>
<Border x:Name="Data"
Height="40">
<Grid x:Name="ContentBase"
Margin="1,0">
<Label Name="DisplayText"
Margin="0"
Padding="0"
HorizontalAlignment="Left"
Content="{Binding Name}"
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=Self}}"/>
</Grid>
</Border>
</DataTemplate>
<converters:IntToBooleanConverter x:Key="IntToBoolConverter"/>
в <DataTemplate.Resources>
. Только так он появился в списке.<ListBox Grid.Row="0"
Name="ListDevices"
Margin="-1"
ItemsSource="{Binding items}"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
SelectionChanged="ProcessingSelect">
<Separator Foreground="LightGray" Background="LightGray" Padding="0" Margin="0"/>
<ListBoxItem Content="№ 1" ContentTemplate="{DynamicResource SelectContext}"/>
<ListBoxItem Content="№ 2" ContentTemplate="{DynamicResource SelectContext}"/>
<ListBoxItem Content="№ 3" ContentTemplate="{DynamicResource SelectContext}"/>
<ListBoxItem Content="№ 4" ContentTemplate="{DynamicResource SelectContext}"/>
<Separator Foreground="Black" Padding="0" Margin="0"/>
<ListBoxItem Content="A" ContentTemplate="{DynamicResource ContentContext}"/>
</ListBox>
public Libraries.ItemsList items = new Libraries.ItemsList();
public DevicesPanel()
{
InitializeComponent();
ListDevices.DataContext = items;
items.Items.CollectionChanged += Items_CollectionChanged;
}