fixed binding for start menu,

removed inverted converter, not required anymore
master
Jonas Arnold 3 years ago
parent 232829b53f
commit e9a5424d1a
  1. 25
      MultiTerm.Wpf/Helpers/InvertedExtension.cs
  2. 23
      MultiTerm.Wpf/ValueConverters/InverterConverter.cs
  3. 20
      MultiTerm.Wpf/View/ShellView.xaml

@ -1,25 +0,0 @@
using MultiTerm.Wpf.ValueConverters;
using System;
using System.Windows.Data;
using System.Windows.Markup;
namespace MultiTerm.Wpf.Helpers;
/// <summary>
/// Extension that uses an <see cref="InverterConverter"/>.
/// Inspired by: https://stackoverflow.com/questions/58519440/is-there-some-way-to-invert-a-converter
/// </summary>
public class InvertedExtension : MarkupExtension
{
public IValueConverter Converter { get; set; }
public InvertedExtension(IValueConverter converter)
{
Converter = new InverterConverter() { Converter = converter };
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return Converter;
}
}

@ -1,23 +0,0 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace MultiTerm.Wpf.ValueConverters;
/// <summary>
/// Reverses <see cref="IValueConverter"/>s.
/// </summary>
public class InverterConverter : IValueConverter
{
public IValueConverter? Converter { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Converter.ConvertBack(value, targetType, parameter, culture);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Converter.Convert(value, targetType, parameter, culture);
}
}

@ -317,18 +317,26 @@
<Label Content="Protocol type:"/> <Label Content="Protocol type:"/>
<!-- ListBox with Protocol types--> <!-- ListBox with Protocol types-->
<ListBox BorderBrush="Transparent" <ListBox BorderBrush="Transparent"
ItemsSource="{Binding Source={StaticResource ProtocolTypeValues}, Converter={StaticResource EnumValToDescConv}}" ItemsSource="{Binding Source={StaticResource ProtocolTypeValues}}"
SelectionMode="Single"
x:Name="listBoxStartMenuProtocols"> x:Name="listBoxStartMenuProtocols">
<ListBox.Resources> <ListBox.Resources>
<Style TargetType="{x:Type ListBoxItem}"> <Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate> <ControlTemplate>
<!-- Button Command binds with DataContext of parent ListBox, CommandParameter binds with the item --> <Button Margin="0 2" Width="Auto" HorizontalContentAlignment="Stretch"
<Button Margin="0 2" Command="{Binding Path=Data.AppendTerminalWithSelectedViewTypeCommand, Source={StaticResource proxy}}"
Content="{TemplateBinding ContentPresenter.Content}"> CommandParameter="{Binding Path=.}">
<!--Command="{Binding Path=DataContext.AppendTerminalWithSelectedViewTypeTestCommand, ElementName=listBoxStartMenuProtocols}" <DockPanel LastChildFill="False">
CommandParameter="{Binding Path=., Converter={helpers:Inverted {StaticResource EnumValToDescConv}}}">--> <Image DockPanel.Dock="Left"
Height="17" Stretch="Fill" Margin="5 0 0 0"
Source="{Binding Path=., Converter={StaticResource ProtocolTypeIconConverter}}"
ToolTip="{Binding Path=., Converter={StaticResource EnumValToDescConv}}"
ToolTipService.InitialShowDelay="200"/>
<TextBlock DockPanel.Dock="Left" Margin="10 0 10 0"
Text="{Binding Path=., Converter={StaticResource EnumValToDescConv}}"/>
</DockPanel>
</Button> </Button>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>

Loading…
Cancel
Save