/// <summary>
        /// focus ListBox item as an asynchronous operation.
        /// </summary>
        /// <param name="mod">The mod.</param>
        /// <param name="scrollToSelected">if set to <c>true</c> [scroll to selected].</param>
        /// <returns>A Task representing the asynchronous operation.</returns>
        protected virtual async Task FocusListBoxItemAsync(IMod mod, bool scrollToSelected)
        {
            await Task.Delay(100);

            var listboxItems = modList.GetLogicalChildren().Cast <ListBoxItem>();

            if (mod != null)
            {
                foreach (var item in listboxItems)
                {
                    var grid = item.GetLogicalChildren().OfType <Grid>().FirstOrDefault();
                    if (grid != null)
                    {
                        var contentMod = item.Content as IMod;
                        if (mod == contentMod)
                        {
                            grid.Focus();
                        }
                    }
                }
                // Because avalonia
                if (scrollToSelected)
                {
                    modList.ScrollIntoView(mod);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// focus order textbox as an asynchronous operation.
        /// </summary>
        /// <param name="mod">The mod.</param>
        protected virtual async Task FocusOrderTextboxAsync(IMod mod)
        {
            await Task.Delay(100);

            var listboxItems = modList.GetLogicalChildren().Cast <ListBoxItem>();

            if (mod != null)
            {
                foreach (var item in listboxItems)
                {
                    var grid = item.GetLogicalChildren().OfType <Grid>().FirstOrDefault();
                    if (grid != null)
                    {
                        var contentMod = item.Content as IMod;
                        if (mod == contentMod)
                        {
                            grid.Focus();
                        }
                    }
                }
            }
        }