Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Microsoft.Toolkit.Future/Adorners/AdornerDecorator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand All @@ -11,7 +11,7 @@ namespace CommunityToolkit.WinUI.Controls.Future;
/// <summary>
/// Helper class to hold content with an <see cref="AdornerLayer"/>. Use this to wrap another <see cref="UIElement"/> and direct where the <see cref="AdornerLayer"/> should sit. This class is helpful to constrain the <see cref="AdornerLayer"/> or in cases where an appropriate location for the layer can't be automatically determined.
/// </summary>
[TemplatePart(Name = PartAdornerLayer, Type = typeof(AdornerLayer))]
[TemplatePart(Name = PartAdornerLayer, Type =typeof(AdornerLayer))]
[ContentProperty(Name = nameof(Child))]
public sealed class AdornerDecorator : Control
{
Expand Down Expand Up @@ -40,4 +40,4 @@ protected override void OnApplyTemplate()

AdornerLayer = GetTemplateChild(PartAdornerLayer) as AdornerLayer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ namespace CommunityToolkit.WinUI.Behaviors.Future;
/// <summary>
/// Behavior which allows for binding to the IsSelected property of a <see cref="ListViewItem"/>.
/// </summary>
#if UNO
public class ListViewItemSelectedBehavior : CommunityToolkit.WinUI.Behaviors.BehaviorBase<FrameworkElement>
#else
public class ListViewItemSelectedBehavior : BehaviorBase<FrameworkElement>
#endif
Comment on lines +15 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just use the fully qualified name for both cases, right? just have a comment as to why. I guess there's some conflict with a similar named class in Uno?

{
WeakReference<ListViewItem>? _parentContainer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Microsoft.Toolkit.Future.Converters;

[Bindable]
public class CollectionContainsConverter : DependencyObject, IValueConverter // BoolToObjectConverter???
public partial class CollectionContainsConverter : DependencyObject, IValueConverter // BoolToObjectConverter???
{
public IEnumerable<object> Collection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ private static void OnAllowDeselectionChanged(DependencyObject obj, DependencyPr
}
}

#if UNO
private static void OnTapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
#else
private static void OnTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
#endif
Comment on lines +59 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An easier approach for all these may be global namespaces which we'd need to use later eventually to support both UWP + WinUI 3.

{
if (sender is ListBox listBox)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public class GetPivotCloseButtonCommandConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
#if UNO
var pivot = (value as DependencyObject)?.FindAscendant<Microsoft.UI.Xaml.Controls.Pivot>();
#else
var pivot = (value as DependencyObject)?.FindAscendant<Windows.UI.Xaml.Controls.Pivot>();
#endif

if (pivot != null)
{
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the Pivot stuff probably isn't even used anymore, the original prototype version from like 2017 used to use Pivot before a change to ListBox, and now NavigationView is used... It may be easier to just remove some of these old things that aren't used anymore.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public virtual object Convert(object value, Type targetType, object parameter, s
var panel = pivotheader?.Parent as PivotHeaderPanel;
var index = panel?.Children?.IndexOf(pivotheader);

#if UNO
var pivot = (value as DependencyObject)?.FindAscendant<Microsoft.UI.Xaml.Controls.Pivot>();
#else
var pivot = (value as DependencyObject)?.FindAscendant<Windows.UI.Xaml.Controls.Pivot>();
#endif

if (index != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public partial class PivotExtensions
/// </summary>
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.Pivot"/> from which to get the associated <see cref="Style"/> instance</param>
/// <returns>The <see cref="Style"/> instance associated with the the <see cref="Windows.UI.Xaml.Controls.Pivot"/> or null</returns>
#if UNO
public static Style GetPivotHeaderItemStyle(Microsoft.UI.Xaml.Controls.Pivot obj)
#else
public static Style GetPivotHeaderItemStyle(Windows.UI.Xaml.Controls.Pivot obj)
#endif
{
return (Style)obj.GetValue(PivotHeaderItemStyleProperty);
}
Expand All @@ -30,7 +34,11 @@ public static Style GetPivotHeaderItemStyle(Windows.UI.Xaml.Controls.Pivot obj)
/// </summary>
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.Pivot"/> to associated the <see cref="Style"/> instance to</param>
/// <param name="value">The <see cref="Style"/> instance to bind to the <see cref="Windows.UI.Xaml.Controls.Pivot"/></param>
#if UNO
public static void SetPivotHeaderItemStyle(Microsoft.UI.Xaml.Controls.Pivot obj, Style value)
#else
public static void SetPivotHeaderItemStyle(Windows.UI.Xaml.Controls.Pivot obj, Style value)
#endif
{
obj.SetValue(PivotHeaderItemStyleProperty, value);
}
Expand Down Expand Up @@ -98,7 +106,11 @@ public static void SetImageSource(PivotItem obj, ImageSource value)
/// </summary>
/// <param name="obj">Pivot to get value from.</param>
/// <returns>Command value for the MSEdgeTabStyle Close Button.</returns>
#if UNO
public static ICommand GetCloseButtonCommand(Microsoft.UI.Xaml.Controls.Pivot obj)
#else
public static ICommand GetCloseButtonCommand(Windows.UI.Xaml.Controls.Pivot obj) // TODO: Should this be per PivotHeaderItem? Thinking no?
#endif
{
return (ICommand)obj.GetValue(CloseButtonCommandProperty);
}
Expand All @@ -108,7 +120,11 @@ public static ICommand GetCloseButtonCommand(Windows.UI.Xaml.Controls.Pivot obj)
/// </summary>
/// <param name="obj">Pivot to set value for.</param>
/// <param name="value">Command value for the MSEdgeTabStyle Close Button.</param>
#if UNO
public static void SetCloseButtonCommand(Microsoft.UI.Xaml.Controls.Pivot obj, ICommand value)
#else
public static void SetCloseButtonCommand(Windows.UI.Xaml.Controls.Pivot obj, ICommand value)
#endif
{
obj.SetValue(CloseButtonCommandProperty, value);
}
Expand All @@ -124,7 +140,11 @@ public static void SetCloseButtonCommand(Windows.UI.Xaml.Controls.Pivot obj, ICo
/// </summary>
/// <param name="obj">Pivot to get value from.</param>
/// <returns>False is content will be hidden.</returns>
#if UNO
public static bool GetIsContentVisible(Microsoft.UI.Xaml.Controls.Pivot obj)
#else
public static bool GetIsContentVisible(Windows.UI.Xaml.Controls.Pivot obj)
#endif
{
return (bool)obj.GetValue(IsContentVisibleProperty);
}
Expand All @@ -134,7 +154,11 @@ public static bool GetIsContentVisible(Windows.UI.Xaml.Controls.Pivot obj)
/// </summary>
/// <param name="obj">Pivot to set value for.</param>
/// <param name="value">Set to false to hide the PivotItemsPresenter.</param>
#if UNO
public static void SetIsContentVisible(Microsoft.UI.Xaml.Controls.Pivot obj, bool value)
#else
public static void SetIsContentVisible(Windows.UI.Xaml.Controls.Pivot obj, bool value)
#endif
{
obj.SetValue(IsContentVisibleProperty, value);
}
Expand Down
21 changes: 20 additions & 1 deletion Microsoft.Toolkit.Future/Extensions/Pivot/PivotExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public partial class PivotExtensions
{
private static void InitPivotStyle(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
#if UNO
var pivot = d as Microsoft.UI.Xaml.Controls.Pivot;
#else
var pivot = d as Windows.UI.Xaml.Controls.Pivot;
#endif

if (pivot == null)
{
Expand All @@ -31,11 +35,18 @@ private static void InitPivotStyle(DependencyObject d, DependencyPropertyChanged

private static void Pivot_Loaded(object sender, RoutedEventArgs e)
{
#if UNO
var pivot = sender as Microsoft.UI.Xaml.Controls.Pivot;
#else
var pivot = sender as Windows.UI.Xaml.Controls.Pivot;
#endif

#if UNO
var panels = pivot.FindDescendants().OfType<Microsoft.UI.Xaml.Controls.Primitives.PivotHeaderPanel>().Where(panel => panel.FindAscendant<Microsoft.UI.Xaml.Controls.Pivot>() == pivot);
#else
// Make sure we find the PivotHeaderPanels for just this Pivot (in case we have embedded pivots)
var panels = pivot.FindDescendants().OfType<PivotHeaderPanel>().Where(panel => panel.FindAscendant<Windows.UI.Xaml.Controls.Pivot>() == pivot);

#endif
var style = GetPivotHeaderItemStyle(pivot);

foreach (var panel in panels)
Expand Down Expand Up @@ -74,7 +85,11 @@ private static void Pivot_Loaded(object sender, RoutedEventArgs e)

private static void IsContentVisible_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
#if UNO
var pivot = d as Microsoft.UI.Xaml.Controls.Pivot;
#else
var pivot = d as Windows.UI.Xaml.Controls.Pivot;
#endif

pivot.Loaded -= Pivot_Loaded;
pivot.Loaded += Pivot_Loaded;
Expand All @@ -85,7 +100,11 @@ private static void IsContentVisible_Changed(DependencyObject d, DependencyPrope
}
}

#if UNO
private static void SetContentVisible(Microsoft.UI.Xaml.Controls.Pivot pivot, bool value)
#else
private static void SetContentVisible(Windows.UI.Xaml.Controls.Pivot pivot, bool value)
#endif
{
// Make sure we find the PivotHeaderPanels for just this Pivot (in case we have embedded pivots)
var presenter = pivot.FindDescendant("PivotItemPresenter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,23 @@ public void AddDefaultSuggestions(List<CompletionItem> items, List<XmlnsNamespac
{
foreach (var t in types.Where(t => t.IsSubclassOf(typeof(DependencyObject))))
{
#if UNO
items.Add(new CompletionItem(t.Name, "", CompletionItemKind.Class)); // TODO:
#else
items.Add(new CompletionItem(t.Name, CompletionItemKind.Class));
#endif
}
}
}

// Add namespace suggestions
foreach (var ns in namespaces)
{
#if UNO
items.Add(new CompletionItem(ns.Name, "", CompletionItemKind.Module)); // TODO:
#else
items.Add(new CompletionItem(ns.Name, CompletionItemKind.Module));
#endif
}
}

Expand All @@ -84,7 +92,11 @@ public void AddNamespaceSuggestions(List<CompletionItem> items, string prefix, L
{
foreach (var t in types.Where(t => t.IsSubclassOf(typeof(DependencyObject))))
{
#if UNO
items.Add(new CompletionItem(t.Name, "", CompletionItemKind.Class));
#else
items.Add(new CompletionItem(t.Name, CompletionItemKind.Class));
#endif
}
}
}
Expand All @@ -101,8 +113,12 @@ public void AddPropertySuggestions(List<CompletionItem> items, string tagName)
{
foreach (var property in GetDependencyProperties(type))
{
#if UNO
items.Add(new CompletionItem(property.Name.Substring(0, property.Name.Length - 8), "", CompletionItemKind.Property));
#else
// Trim 'Property' off DependencyProperty name.
items.Add(new CompletionItem(property.Name.Substring(0, property.Name.Length - 8), CompletionItemKind.Property));
#endif
}
}
}
Expand All @@ -122,7 +138,11 @@ public void AddValueSuggestions(List<CompletionItem> items, string tagName, stri
{
foreach (var value in Enum.GetNames(prop.PropertyType))
{
#if UNO
items.Add(new CompletionItem(value, "", CompletionItemKind.Value));
#else
items.Add(new CompletionItem(value, CompletionItemKind.Value));
#endif
}
}
// FontWeights...grrr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ public IAsyncOperation<CompletionList> ProvideCompletionItemsAsync(IModel model,
{
if (index >= 1 && text[index - 1] == '<')
{
#if UNO
items.Add(new CompletionItem(parentTagName, "", CompletionItemKind.Class));
#else
// Only show suggestion if we're starting a close tag.
items.Add(new CompletionItem(parentTagName, CompletionItemKind.Class));
#endif
}
}
else if (context.TriggerCharacter == ElementTrigger)
Expand Down Expand Up @@ -101,7 +105,11 @@ public IAsyncOperation<CompletionList> ProvideCompletionItemsAsync(IModel model,

return new CompletionList()
{
#if UNO
Suggestions = items.ToArray()
#else
Items = items
#endif
};
});
}
Expand All @@ -110,4 +118,18 @@ public IAsyncOperation<CompletionItem> ResolveCompletionItemAsync(CompletionItem
{
throw new NotImplementedException();
}

#if UNO
public async Task<CompletionList> ProvideCompletionItemsAsync(IModel model, Position position, CompletionContext context)
{
// Forward to the WinRT-style implementation and unwrap the result
var op = ProvideCompletionItemsAsync((IModel)model, (IPosition)position, context);
return await op.AsTask().ConfigureAwait(false);
}

public async Task<CompletionItem> ResolveCompletionItemAsync(IModel model, CompletionItem item)
{
throw new NotImplementedException();
}
#endif
}
4 changes: 3 additions & 1 deletion XamlStudio.Toolkit/Services/XamlXmlTreeCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public class XamlXmlTreeCoordinator
{ nameof(UIElement.RenderTransformOrigin), UIElement.RenderTransformOriginProperty },
{ nameof(UIElement.Shadow), UIElement.ShadowProperty },
{ nameof(UIElement.Transform3D), UIElement.Transform3DProperty },
{ nameof(UIElement.Transitions), UIElement.TransitionsProperty },
#if !UNO
{ nameof(UIElement.Transitions), UIElement.TransitionsProperty }, // TODO: https://github.com/unoplatform/uno/issues/22288
#endif
{ nameof(UIElement.UseLayoutRounding), UIElement.UseLayoutRoundingProperty },
{ nameof(UIElement.Visibility), UIElement.VisibilityProperty },
{ nameof(UIElement.XYFocusDownNavigationStrategy), UIElement.XYFocusDownNavigationStrategyProperty },
Expand Down
12 changes: 10 additions & 2 deletions XamlStudio/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public App()

// Deferred execution until used. Check https://msdn.microsoft.com/library/dd642331(v=vs.110).aspx for further info on Lazy<T> class.
_activationService = new Lazy<ActivationService>(CreateActivationService);

#if !UNO
try
{
AppCenter.SetCountryCode(new Windows.Globalization.GeographicRegion().CodeTwoLetter);
Expand All @@ -54,28 +54,32 @@ public App()
}
AppCenter.Start("", typeof(Analytics));
AppCenter.Start("", typeof(Crashes));
#endif
}

protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
#if !UNO
if (!args.PrelaunchActivated)
{
AppLoggerService.LogInfo($"[AppActivation] Application activated by {args.Kind}");
await ActivationService.ActivateAsync(args);
}
#endif
}

protected override async void OnActivated(IActivatedEventArgs args)
{
AppLoggerService.LogInfo($"[AppActivation] Application activated by {args.Kind}");
await ActivationService.ActivateAsync(args);
}

#if !UNO
protected override async void OnFileActivated(FileActivatedEventArgs args)
{
AppLoggerService.LogInfo($"[AppActivation] Application activated by {args.Kind}");
await ActivationService.ActivateAsync(args);
}
#endif

private ActivationService CreateActivationService()
{
Expand Down Expand Up @@ -132,7 +136,11 @@ private void App_Resuming(object sender, object e)
/// <summary>
/// Handles the event of an unhandles exception bubbling up all the way to the App instance.
/// </summary>
#if UNO
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
#else
private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
#endif
{
// TODO: Check if these are coming from a Render call and just ignore then.# (this is usually the case, but doesn't save us)
e.Handled = true;
Expand Down
Loading