Skip to content

Commit

Permalink
Fix a bug where tooltip wont appear on combobox items
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajidur78 committed Apr 4, 2020
1 parent 03fb1a3 commit 4a05650
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
21 changes: 16 additions & 5 deletions HedgeModManager/Controls/FormItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,31 @@ public UIElement CreateUiElement(FormElement element)
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch,
Height = 20,
DataContext = element
DataContext = element,
};
enums.ForEach(x => box.Items.Add(x));


foreach (var val in enums)
{
var item = new ComboBoxItem()
{
Content = val.DisplayName,
DataContext = val,
ToolTip = new ToolTip() { Content = string.Join("\r\n", val.Description)}
};
box.Items.Add(item);
}

box.SetBinding(Selector.SelectedValueProperty, "Value");

if (element.Value != null)
{
var value = enums.FirstOrDefault(x => x.Value == element.Value.ToString());
box.SelectedValue = value ?? enums.First();
var i = enums.IndexOf(value);
box.SelectedIndex= i < 0 ? 0 : i;
}
else
{
box.SelectedValue = enums.First();
box.SelectedIndex = 0;
}

return box;
Expand Down
2 changes: 1 addition & 1 deletion HedgeModManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.1.0.0")]
[assembly: AssemblyVersion("7.1.0.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 2 additions & 2 deletions HedgeModManager/UI/FormBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public void SaveIni(string path)
{
foreach (var element in group.Elements)
{
if (element.Value is FormEnum)
file[group.Name][element.Name] = ((FormEnum)element.Value)?.Value;
if (element.Value is FrameworkElement && ((FrameworkElement)element.Value).DataContext is FormEnum)
file[group.Name][element.Name] = ((FormEnum)((FrameworkElement)element.Value).DataContext)?.Value;
else
file[group.Name][element.Name] = element.Value?.ToString() ?? element.DefaultValue.ToString();
}
Expand Down
2 changes: 1 addition & 1 deletion HedgeModManager/UI/ModConfigWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</Grid.RowDefinitions>

<ScrollViewer Margin="15">
<Grid x:Name="ItemsHost"/>
<Grid x:Name="ItemsHost" Margin="15,0"/>
</ScrollViewer>
<StackPanel Orientation="Horizontal" FlowDirection="RightToLeft" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="-4" Grid.Row="1" Background="{StaticResource HMM.Window.DialogBottom}">
<Button Content="{StaticResource CommonUICancel}" Margin="8,0,0,0" VerticalAlignment="Center" Width="75" Height="23" Click="UI_Cancel_Click"/>
Expand Down

0 comments on commit 4a05650

Please sign in to comment.