Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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: 5 additions & 1 deletion Microsoft.Toolkit.Future/Adorners/AdornerDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ 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))]
#if UNO
[ContentProperty(nameof(Child))]
#else
[ContentProperty(Name = nameof(Child))]
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This class is going away in #42

public sealed class AdornerDecorator : Control
{
private const string PartAdornerLayer = "AdornerLayer";
Expand Down
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 @@ -110,4 +110,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
}