<ContentControl Grid.Row="1" Name="Channel_1" Content="{Binding ControlChannelDevice[0]}"/>
<ContentControl Grid.Row="1" Name="Channel_2" Content="{Binding ControlChannelDevice[1]}"/>
<ContentControl Grid.Row="1" Name="Channel_3" Content="{Binding ControlChannelDevice[2]}"/>
<ContentControl Grid.Row="1" Name="Channel_4" Content="{Binding ControlChannelDevice[3]}"/>
Channel_1.DataContext = ControlChannelsDevice;
Channel_2.DataContext = ControlChannelsDevice;
Channel_3.DataContext = ControlChannelsDevice;
Channel_4.DataContext = ControlChannelsDevice;
<DataTemplate x:Key="SelectContext">
<Border x:Name="Data">
<Grid x:Name="ContentBase" Margin="1,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Margin="0"
Padding="0"
HorizontalAlignment="Left"
Content="{Binding Content, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContentPresenter}}"
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContentPresenter}}" />
<RadioButton
Name="_1"
Grid.Column="1"
Content="1"
Style="{StaticResource RadioButtonKeys}" />
<RadioButton
Name="_2"
Grid.Column="2"
Content="2"
Style="{StaticResource RadioButtonKeys}" />
<RadioButton
Name="_3"
Grid.Column="3"
Content="3"
Style="{StaticResource RadioButtonKeys}" />
</Grid>
</Border>
</DataTemplate>
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContentPresenter}}"
на Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=Self}}"
<!-- ListBoxItem -->
<Style x:Key="Item"
BasedOn="{x:Null}"
TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Height" Value="42"/>
<Setter Property="Margin" Value="-2,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid x:Name="ListItem">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="ListItem_Text"
Grid.Column="0"
Padding="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="13"
FontWeight="Medium"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Content}"/>
<RadioButton x:Name="PART_SelectVariable_1"
Grid.Column="1"
Content="Вариант 1"
IsEnabled="{TemplateBinding IsEnabled}"
Style="{StaticResource {x:Type ToggleButton}}"/>
<RadioButton x:Name="PART_SelectVariable_2"
Grid.Column="2"
Content="Вариант 2"
IsEnabled="{TemplateBinding IsEnabled}"
Style="{StaticResource {x:Type ToggleButton}}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ListItem" Property="Background" Value="#FF203FE6"/>
<Setter TargetName="ListItem_Text" Property="Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ListItem" Property="Background" Value="LightGray"/>
<Setter TargetName="ListItem_Text" Property="Foreground" Value="DarkGray"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="ListItem" Property="Background" Value="#FFFDDFAD"/>
<Setter TargetName="ListItem_Text" Property="Foreground" Value="#FFA47C38"/>
</Trigger>
<Trigger Property="local:Styles.IsRadioButton" Value="-1">
<Setter Property="DataContext" Value="0"/>
<Setter TargetName="PART_SelectVariable_1" Property="IsChecked" Value="false"/>
<Setter TargetName="PART_SelectVariable_2" Property="IsChecked" Value="false"/>
</Trigger>
<DataTrigger Binding="{Binding ElementName=PART_SelectVariable_1, Path=IsPressed}"
Value="True">
<Setter TargetName="ListItem" Property="Background" Value="#FFE8E9F2"/>
<Setter TargetName="ListItem_Text" Property="Foreground" Value="#FF9A9FB8"/>
<Setter Property="local:Styles.IsRadioButton" Value="1"/>
<Setter Property="IsSelected" Value="True"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=PART_SelectVariable_2, Path=IsPressed}"
Value="True">
<Setter TargetName="ListItem" Property="Background" Value="#FFE8E9F2"/>
<Setter TargetName="ListItem_Text" Property="Foreground" Value="#FF9A9FB8"/>
<Setter Property="local:Styles.IsRadioButton" Value="2"/>
<Setter Property="IsSelected" Value="True"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
public struct Top
{
public Response response;
public struct Response
{
public int count;
public int[] items;
}
}
public class Intercom
{
#region Обработка событий по изменению содержимых.
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
#region Управление свойством.
public string Message { get; set; } = "Null";
public bool OnEvent { get; set; } = true;
public void Reset() { Message = "Null"; }
#endregion
#region Внутренее свойство события.
private int _Calling;
private string _Response;
private string _Request;
private string _Report;
public int Calling
{
get { return _Calling; }
set { _Calling = value; if (OnEvent) NotifyPropertyChanged($"Call.{Message}"); }
}
public string Response
{
get { return _Response; }
set { _Response = value; if (OnEvent) NotifyPropertyChanged($"Response.{Message}"); }
}
public string Request
{
get { return _Request; }
set { _Request = value; if (OnEvent) NotifyPropertyChanged($"Request.{Message}"); }
}
public string Report
{
get { return _Report; }
set { _Report = value; if (OnEvent) NotifyPropertyChanged($"Report.{Message}"); }
}
#endregion
}