< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .
< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .< Window.Resources > < local:SolarSystem x:Key =β solarSystem β /> (β¦) </ Window.Resources > < ListBox ItemsSource =β{ Binding Source ={ StaticResource solarSystem }, Path = SolarSystemObjects }β /> * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- < Style TargetType = β ListBox β >
 - < Setter Property = β ItemsPanel β >
 - < Setter.Value >
 - < ItemsPanelTemplate >
 - < Canvas Width = β 590 ? Height = β 590 ? Background = " Black " />
 - </ ItemsPanelTemplate >
 - </ Setter.Value >
 - </ Setter >
 - </ Style >
 
* This source code was highlighted with Source Code Highlighter .
- < DataTemplate DataType = "{x: Type local: SolarSObject}" >
 - < Canvas Width = "20" Height = "20" >
 - < Ellipse
 - Canvas . Left = "{Binding Path = Orbit, Converter = {StaticResource convertOrbit}, ConverterParameter = -1.707}"
 - Canvas . Top = "{Binding Path = Orbit, Converter = {StaticResource convertOrbit}, ConverterParameter = -0.293}"
 - Width = "{Binding Path = Orbit, Converter = {StaticResource convertOrbit}, ConverterParameter = 2}"
 - Height = "{Binding Path = Orbit, Converter = {StaticResource convertOrbit}, ConverterParameter = 2}"
 - Stroke = "White"
 - StrokeThickness = "1" />
 - < Image Source = "{Binding Path = Image}" Width = "20" Height = "20" >
 - < Image.ToolTip >
 - < StackPanel Width = "250" TextBlock . FontSize = "12" >
 - < TextBlock FontWeight = "Bold" Text = "{Binding Path = Name}" />
 - < StackPanel Orientation = "Horizontal" >
 - < TextBlock Text = "Orbit:" />
 - < TextBlock Text = "{Binding Path = Orbit}" />
 - < TextBlock Text = "AU" />
 - </ StackPanel >
 - < TextBlock Text = "{Binding Path = Details}" TextWrapping = "Wrap" />
 - </ StackPanel >
 - </ Image.ToolTip >
 - </ Image >
 - </ Canvas >
 - </ DataTemplate >
 - < Style TargetType = "ListBoxItem" >
 - < Setter Property = "Canvas.Left" Value = "{Binding Path = Orbit, Converter = {StaticResource convertOrbit}, ConverterParameter = 0.707}" />
 - < Setter Property = "Canvas. Bottom" Value = "{Binding Path = Orbit, Converter = {StaticResource convertOrbit}, ConverterParameter = 0.707}" />
 - (...)
 - </ Style >
 
* This source code was highlighted with Source Code Highlighter .
- public class ConvertOrbit: IValueConverter
 - {
 - public object Convert ( object value , Type targetType, object parameter, CultureInfo culture)
 - {
 - double orbit = ( double ) value ;
 - double factor = System. Convert .ToDouble (Parameter);
 - return Math .Pow (orbit / 40, 0.4) * 770 * factor;
 - }
 - public object ConvertBack ( object value , Type targetType, object parameter, CultureInfo culture)
 - {
 - throw new NotSupportedException ("This method should never be called");
 - }
 - }
 
* This source code was highlighted with Source Code Highlighter .
- < Setter Property = β Template β >
 - < Setter.Value >
 - < ControlTemplate TargetType = β{ x: Type ListBoxItem }β >
 - < Border SnapsToDevicePixels = β true β x: Name = β Bd β Background = β{ TemplateBinding Background }β β BorderBrush =β { TemplateBinding BorderBrush } β BorderThickness =β { TemplateBinding BorderThickness } β Padding =β { TemplateBinding Padding } β >
 - < ContentPresenter SnapsToDevicePixels = β{ TemplateBinding SnapsToDevicePixels }β HorizontalAlignment = β{ TemplateBinding HorizontalContentAlignment }β VerticalAlignment = β{ TemplateBinding VerticalContentAlignment }β />
 - </ Border >
 - < ControlTemplate.Triggers >
 - < Trigger Property = β IsSelected β Value = β true β >
 - < Setter Property = β Background β TargetName = β Bd β Value = β{ DynamicResource { x: Static SystemColors . HighlightBrushKey }} β />
 - < Setter Property = β Foreground β Value = β{ DynamicResource { x: Static SystemColors . HighlightTextBrushKey }} β />
 - </ Trigger >
 - < MultiTrigger >
 - < MultiTrigger.Conditions >
 - < Condition Property = β IsSelected β Value = β true β />
 - < Condition Property = β Selector . IsSelectionActive β Value =β false β />
 - </ MultiTrigger.Conditions >
 - < Setter Property = β Background β TargetName = β Bd β Value = β{ DynamicResource { x: Static SystemColors . ControlBrushKey }} β />
 - < Setter Property = β Foreground β Value = β{ DynamicResource { x: Static SystemColors . ControlTextBrushKey }} β />
 - </ MultiTrigger >
 - < Trigger Property = β IsEnabled β Value = β false β >
 - < Setter Property = β Foreground β Value = β{ DynamicResource { x: Static SystemColors . GrayTextBrushKey }} β />
 - </ Trigger >
 - </ ControlTemplate.Triggers >
 - </ ControlTemplate >
 - </ Setter.Value >
 - </ Setter >
 
* This source code was highlighted with Source Code Highlighter .
- < Style TargetType = β ListBoxItem β >
 - (...)
 - < Setter Property = β Template β >
 - < Setter.Value >
 - < ControlTemplate TargetType = β{ x: Type ListBoxItem }β >
 - < Grid >
 - < Ellipse x: Name = β selectedPlanet β Margin = β -10 β StrokeThickness = β 2 β />
 - < ContentPresenter SnapsToDevicePixels = β{ TemplateBinding SnapsToDevicePixels }β
 - HorizontalAlignment = β{ TemplateBinding HorizontalContentAlignment }β
 - VerticalAlignment = β{ TemplateBinding VerticalContentAlignment }β />
 - </ Grid >
 - < ControlTemplate.Triggers >
 - < Trigger Property = β IsSelected β Value = β true β >
 - < Setter Property = β Stroke β TargetName = β selectedPlanet β Value = β Yellow β />
 - </ Trigger >
 - </ ControlTemplate.Triggers >
 - </ ControlTemplate >
 - </ Setter.Value >
 - </ Setter >
 - </ Style >
 
Source: https://habr.com/ru/post/43474/
All Articles