Skip to content

Commit

Permalink
Avalonia v11 - Items to ItemsSource
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSuess committed Jul 30, 2023
1 parent 6d47067 commit 5ddf1f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ILSpy.Core/Controls/ResourceStringTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class ResourceStringTable : UserControl, IRoutedCommandBindable
public ResourceStringTable(IEnumerable strings, ContentPresenter contentPresenter)
{
InitializeComponent();
resourceListView.Items = strings;
resourceListView.ItemsSource = strings;
}

private void InitializeComponent()
Expand Down Expand Up @@ -77,4 +77,4 @@ void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
args.CanExecute = true;
}
}
}
}
11 changes: 6 additions & 5 deletions ILSpy.Core/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
using AvaloniaEdit;
using AvaloniaEdit.Highlighting;
using AvaloniaEdit.Highlighting.Xshd;
using AvaloniaEdit.Utils;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Documentation;
using ICSharpCode.Decompiler.Metadata;
Expand Down Expand Up @@ -341,7 +342,7 @@ void InitToolbar()
int navigationPos = 0;
int openPos = 1;
var toolbarCommands = App.ExportProvider.GetExports<ICommand, IToolbarCommandMetadata>("ToolbarCommand");
var toolbarItems = toolBar.Items as IList<object> ?? new List<object>();
var toolbarItems = toolBar.ItemsSource as IList<object> ?? new List<object>();
foreach (var commandGroup in toolbarCommands.OrderBy(c => c.Metadata.ToolbarOrder).GroupBy(c => Properties.Resources.ResourceManager.GetString(c.Metadata.ToolbarCategory))) {
if (commandGroup.Key == Properties.Resources.ResourceManager.GetString("Navigation")) {
foreach (var command in commandGroup) {
Expand Down Expand Up @@ -386,7 +387,7 @@ Button MakeToolbarItem(Lazy<ICommand, IToolbarCommandMetadata> command)
void InitMainMenu()
{
var mainMenuCommands = App.ExportProvider.GetExports<ICommand, IMainMenuCommandMetadata>("MainMenuCommand");
var mainMenuItems = mainMenu.Items as IList<object> ?? new List<object>();
var mainMenuItems = mainMenu.ItemsSource as IList<object> ?? new List<object>();
foreach (var topLevelMenu in mainMenuCommands.OrderBy(c => c.Metadata.MenuOrder).GroupBy(c => GetResourceString(c.Metadata.Menu))) {
MenuItem topLevelMenuItem = mainMenu.Items.OfType<MenuItem>().FirstOrDefault(m => (GetResourceString(m.Header as string)) == topLevelMenu.Key);
var topLevelMenuItems = topLevelMenuItem?.Items as IList<object> ?? new List<object>();
Expand Down Expand Up @@ -1200,7 +1201,7 @@ async void LoadAssemblies(IEnumerable<string> fileNames, List<LoadedAssembly> lo
// Select only the last node to avoid multi selection
if(lastNode != null) {
treeView.SelectedItem = lastNode;
}
}
}

void RefreshCommandExecuted(object sender, ExecutedRoutedEventArgs e)
Expand Down Expand Up @@ -1528,12 +1529,12 @@ public void SetStatus(string status, IBrush foreground)

public IEnumerable GetMainMenuItems()
{
return mainMenu.Items;
return mainMenu.ItemsSource;
}

public IEnumerable GetToolBarItems()
{
return toolBar.Items;
return toolBar.ItemsSource;
}
}
}
6 changes: 3 additions & 3 deletions SharpTreeView/SharpTreeViewTextSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public bool RevertLastCharacter()

public bool Search(string nextChar)
{
IList items = (IList)treeView.Items;
IList items = (IList)treeView.ItemsSource;
int startIndex = isActive ? lastMatchIndex : Math.Max(0, treeView.SelectedIndex);
bool lookBackwards = inputStack.Count > 0 && string.Compare(inputStack.Peek(), nextChar, StringComparison.OrdinalIgnoreCase) == 0;
int nextMatchIndex = IndexOfMatch(matchPrefix + nextChar, startIndex, lookBackwards, out bool wasNewCharUsed);
Expand All @@ -86,7 +86,7 @@ public bool Search(string nextChar)

int IndexOfMatch(string needle, int startIndex, bool tryBackward, out bool charWasUsed)
{
IList items = (IList)treeView.Items;
IList items = (IList)treeView.ItemsSource;
charWasUsed = false;
if (items.Count == 0 || string.IsNullOrEmpty(needle))
return -1;
Expand Down Expand Up @@ -143,4 +143,4 @@ void ResetTimeout()
timer.Start();
}
}
}
}

0 comments on commit 5ddf1f7

Please sign in to comment.