Merge branch 'mhawker/monaco-update' into mhawker/tabview
# Conflicts: # Microsoft.Toolkit.Uwp.UI/Extensions/Tree/VisualTree.cs
|
@ -4,35 +4,14 @@
|
|||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.Toolkit.Services.Bing;
|
||||
|
||||
namespace Microsoft.Toolkit.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// This class offers general purpose methods.
|
||||
/// </summary>
|
||||
public static class ExtensionMethods
|
||||
internal static class ExtensionMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts between country code and country name.
|
||||
/// </summary>
|
||||
/// <param name="value">BingCountry enumeration.</param>
|
||||
/// <returns>Returns country code.</returns>
|
||||
public static string GetStringValue(this BingCountry value)
|
||||
{
|
||||
return GetStringValue((Enum)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts between language code and language name.
|
||||
/// </summary>
|
||||
/// <param name="value">BingLanguage enumeration.</param>
|
||||
/// <returns>Returns language code.</returns>
|
||||
public static string GetStringValue(this BingLanguage value)
|
||||
{
|
||||
return GetStringValue((Enum)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts between enumeration value and string value.
|
||||
/// </summary>
|
||||
|
|
|
@ -41,10 +41,4 @@
|
|||
<Compile Remove="Services\OneDrive\Platform\Uwp\**\*" />
|
||||
<Compile Remove="PlatformSpecific\Uwp\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\Internal\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
|
@ -1,542 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Toolkit.Parsers.Core;
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Country/region filter for search query.
|
||||
/// </summary>
|
||||
public enum BingCountry
|
||||
{
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
[StringValue("")]
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// United Arab Emirates
|
||||
/// </summary>
|
||||
[StringValue("ae")]
|
||||
UnitedArabEmirates,
|
||||
|
||||
/// <summary>
|
||||
/// Albania
|
||||
/// </summary>
|
||||
[StringValue("al")]
|
||||
Albania,
|
||||
|
||||
/// <summary>
|
||||
/// Armenia
|
||||
/// </summary>
|
||||
[StringValue("am")]
|
||||
Armenia,
|
||||
|
||||
/// <summary>
|
||||
/// Argentina
|
||||
/// </summary>
|
||||
[StringValue("ar")]
|
||||
Argentina,
|
||||
|
||||
/// <summary>
|
||||
/// Austria
|
||||
/// </summary>
|
||||
[StringValue("at")]
|
||||
Austria,
|
||||
|
||||
/// <summary>
|
||||
/// Australia
|
||||
/// </summary>
|
||||
[StringValue("au")]
|
||||
Australia,
|
||||
|
||||
/// <summary>
|
||||
/// Azerbaijan
|
||||
/// </summary>
|
||||
[StringValue("az")]
|
||||
Azerbaijan,
|
||||
|
||||
/// <summary>
|
||||
/// Bosnia and Herzegovina
|
||||
/// </summary>
|
||||
[StringValue("ba")]
|
||||
BosniaHerzegovina,
|
||||
|
||||
/// <summary>
|
||||
/// Belgium
|
||||
/// </summary>
|
||||
[StringValue("be")]
|
||||
Belgium,
|
||||
|
||||
/// <summary>
|
||||
/// Bulgaria
|
||||
/// </summary>
|
||||
[StringValue("bg")]
|
||||
Bulgaria,
|
||||
|
||||
/// <summary>
|
||||
/// Bahrain
|
||||
/// </summary>
|
||||
[StringValue("bh")]
|
||||
Bahrain,
|
||||
|
||||
/// <summary>
|
||||
/// Bolivia
|
||||
/// </summary>
|
||||
[StringValue("bo")]
|
||||
Bolivia,
|
||||
|
||||
/// <summary>
|
||||
/// Brazil
|
||||
/// </summary>
|
||||
[StringValue("br")]
|
||||
Brazil,
|
||||
|
||||
/// <summary>
|
||||
/// Canada
|
||||
/// </summary>
|
||||
[StringValue("ca")]
|
||||
Canada,
|
||||
|
||||
/// <summary>
|
||||
/// Switzerland
|
||||
/// </summary>
|
||||
[StringValue("ch")]
|
||||
Switzerland,
|
||||
|
||||
/// <summary>
|
||||
/// Chile
|
||||
/// </summary>
|
||||
[StringValue("cl")]
|
||||
Chile,
|
||||
|
||||
/// <summary>
|
||||
/// China
|
||||
/// </summary>
|
||||
[StringValue("cn")]
|
||||
China,
|
||||
|
||||
/// <summary>
|
||||
/// Costa Rica
|
||||
/// </summary>
|
||||
[StringValue("cr")]
|
||||
CostaRica,
|
||||
|
||||
/// <summary>
|
||||
/// Germany
|
||||
/// </summary>
|
||||
[StringValue("de")]
|
||||
Germany,
|
||||
|
||||
/// <summary>
|
||||
/// Dominican Republic
|
||||
/// </summary>
|
||||
[StringValue("do")]
|
||||
DominicanRepublic,
|
||||
|
||||
/// <summary>
|
||||
/// Ecuador
|
||||
/// </summary>
|
||||
[StringValue("ec")]
|
||||
Ecuador,
|
||||
|
||||
/// <summary>
|
||||
/// France
|
||||
/// </summary>
|
||||
[StringValue("fr")]
|
||||
France,
|
||||
|
||||
/// <summary>
|
||||
/// United Kingdom
|
||||
/// </summary>
|
||||
[StringValue("uk")]
|
||||
UnitedKingdom,
|
||||
|
||||
/// <summary>
|
||||
/// Georgia
|
||||
/// </summary>
|
||||
[StringValue("ge")]
|
||||
Georgia,
|
||||
|
||||
/// <summary>
|
||||
/// Greece
|
||||
/// </summary>
|
||||
[StringValue("gr")]
|
||||
Greece,
|
||||
|
||||
/// <summary>
|
||||
/// Guatemala
|
||||
/// </summary>
|
||||
[StringValue("gt")]
|
||||
Guatemala,
|
||||
|
||||
/// <summary>
|
||||
/// Hong Kong SAR
|
||||
/// </summary>
|
||||
[StringValue("hk")]
|
||||
HongKong,
|
||||
|
||||
/// <summary>
|
||||
/// Honduras
|
||||
/// </summary>
|
||||
[StringValue("hn")]
|
||||
Honduras,
|
||||
|
||||
/// <summary>
|
||||
/// Croatia
|
||||
/// </summary>
|
||||
[StringValue("hr")]
|
||||
Croatia,
|
||||
|
||||
/// <summary>
|
||||
/// Hungary
|
||||
/// </summary>
|
||||
[StringValue("hu")]
|
||||
Hungary,
|
||||
|
||||
/// <summary>
|
||||
/// Indonesia
|
||||
/// </summary>
|
||||
[StringValue("id")]
|
||||
Indonesia,
|
||||
|
||||
/// <summary>
|
||||
/// Ireland
|
||||
/// </summary>
|
||||
[StringValue("ie")]
|
||||
Ireland,
|
||||
|
||||
/// <summary>
|
||||
/// Israel
|
||||
/// </summary>
|
||||
[StringValue("i")]
|
||||
Israel,
|
||||
|
||||
/// <summary>
|
||||
/// India
|
||||
/// </summary>
|
||||
[StringValue("in")]
|
||||
India,
|
||||
|
||||
/// <summary>
|
||||
/// Iraq
|
||||
/// </summary>
|
||||
[StringValue("iq")]
|
||||
Iraq,
|
||||
|
||||
/// <summary>
|
||||
/// Iran
|
||||
/// </summary>
|
||||
[StringValue("ir")]
|
||||
Iran,
|
||||
|
||||
/// <summary>
|
||||
/// Iceland
|
||||
/// </summary>
|
||||
[StringValue("is")]
|
||||
Iceland,
|
||||
|
||||
/// <summary>
|
||||
/// Italy
|
||||
/// </summary>
|
||||
[StringValue("it")]
|
||||
Italy,
|
||||
|
||||
/// <summary>
|
||||
/// Jordan
|
||||
/// </summary>
|
||||
[StringValue("jo")]
|
||||
Jordan,
|
||||
|
||||
/// <summary>
|
||||
/// Japan
|
||||
/// </summary>
|
||||
[StringValue("jp")]
|
||||
Japan,
|
||||
|
||||
/// <summary>
|
||||
/// Kenya
|
||||
/// </summary>
|
||||
[StringValue("ke")]
|
||||
Kenya,
|
||||
|
||||
/// <summary>
|
||||
/// Korea
|
||||
/// </summary>
|
||||
[StringValue("kr")]
|
||||
Korea,
|
||||
|
||||
/// <summary>
|
||||
/// Kuwait
|
||||
/// </summary>
|
||||
[StringValue("kw")]
|
||||
Kuwait,
|
||||
|
||||
/// <summary>
|
||||
/// Lebanon
|
||||
/// </summary>
|
||||
[StringValue("lb")]
|
||||
Lebanon,
|
||||
|
||||
/// <summary>
|
||||
/// Lithuania
|
||||
/// </summary>
|
||||
[StringValue("lt")]
|
||||
Lithuania,
|
||||
|
||||
/// <summary>
|
||||
/// Latvia
|
||||
/// </summary>
|
||||
[StringValue("lv")]
|
||||
Latvia,
|
||||
|
||||
/// <summary>
|
||||
/// Luxembourg
|
||||
/// </summary>
|
||||
[StringValue("lu")]
|
||||
Luxembourg,
|
||||
|
||||
/// <summary>
|
||||
/// Libya
|
||||
/// </summary>
|
||||
[StringValue("ly")]
|
||||
Libya,
|
||||
|
||||
/// <summary>
|
||||
/// Morocco
|
||||
/// </summary>
|
||||
[StringValue("ma")]
|
||||
Morocco,
|
||||
|
||||
/// <summary>
|
||||
/// Republic of Macedonia
|
||||
/// </summary>
|
||||
[StringValue("mk")]
|
||||
Macedonia,
|
||||
|
||||
/// <summary>
|
||||
/// Malta
|
||||
/// </summary>
|
||||
[StringValue("mt")]
|
||||
Malta,
|
||||
|
||||
/// <summary>
|
||||
/// Malaysia
|
||||
/// </summary>
|
||||
[StringValue("my")]
|
||||
Malaysia,
|
||||
|
||||
/// <summary>
|
||||
/// Mexico
|
||||
/// </summary>
|
||||
[StringValue("mx")]
|
||||
Mexico,
|
||||
|
||||
/// <summary>
|
||||
/// Nicaragua
|
||||
/// </summary>
|
||||
[StringValue("ni")]
|
||||
Nicaragua,
|
||||
|
||||
/// <summary>
|
||||
/// Netherlands
|
||||
/// </summary>
|
||||
[StringValue("nl")]
|
||||
Netherlands,
|
||||
|
||||
/// <summary>
|
||||
/// New Zealand
|
||||
/// </summary>
|
||||
[StringValue("nz")]
|
||||
NewZealand,
|
||||
|
||||
/// <summary>
|
||||
/// Norway
|
||||
/// </summary>
|
||||
[StringValue("no")]
|
||||
Norway,
|
||||
|
||||
/// <summary>
|
||||
/// Oman
|
||||
/// </summary>
|
||||
[StringValue("om")]
|
||||
Oman,
|
||||
|
||||
/// <summary>
|
||||
/// Panama
|
||||
/// </summary>
|
||||
[StringValue("pa")]
|
||||
Panama,
|
||||
|
||||
/// <summary>
|
||||
/// Peru
|
||||
/// </summary>
|
||||
[StringValue("pe")]
|
||||
Peru,
|
||||
|
||||
/// <summary>
|
||||
/// Philippines
|
||||
/// </summary>
|
||||
[StringValue("ph")]
|
||||
Philippines,
|
||||
|
||||
/// <summary>
|
||||
/// Poland
|
||||
/// </summary>
|
||||
[StringValue("pl")]
|
||||
Poland,
|
||||
|
||||
/// <summary>
|
||||
/// Pakistan
|
||||
/// </summary>
|
||||
[StringValue("pk")]
|
||||
Pakistan,
|
||||
|
||||
/// <summary>
|
||||
/// PuertoRico
|
||||
/// </summary>
|
||||
[StringValue("pr")]
|
||||
PuertoRico,
|
||||
|
||||
/// <summary>
|
||||
/// Portugal
|
||||
/// </summary>
|
||||
[StringValue("ru")]
|
||||
Portugal,
|
||||
|
||||
/// <summary>
|
||||
/// Paraguay
|
||||
/// </summary>
|
||||
[StringValue("py")]
|
||||
Paraguay,
|
||||
|
||||
/// <summary>
|
||||
/// Qatar
|
||||
/// </summary>
|
||||
[StringValue("qa")]
|
||||
Qatar,
|
||||
|
||||
/// <summary>
|
||||
/// Romania
|
||||
/// </summary>
|
||||
[StringValue("ro")]
|
||||
Romania,
|
||||
|
||||
/// <summary>
|
||||
/// Russia
|
||||
/// </summary>
|
||||
[StringValue("ru")]
|
||||
Russia,
|
||||
|
||||
/// <summary>
|
||||
/// Sweden
|
||||
/// </summary>
|
||||
[StringValue("se")]
|
||||
Sweden,
|
||||
|
||||
/// <summary>
|
||||
/// Saudi Arabia
|
||||
/// </summary>
|
||||
[StringValue("sa")]
|
||||
SaudiArabia,
|
||||
|
||||
/// <summary>
|
||||
/// Singapore
|
||||
/// </summary>
|
||||
[StringValue("sg")]
|
||||
Singapore,
|
||||
|
||||
/// <summary>
|
||||
/// Slovakia
|
||||
/// </summary>
|
||||
[StringValue("sk")]
|
||||
Slovakia,
|
||||
|
||||
/// <summary>
|
||||
/// Slovenia
|
||||
/// </summary>
|
||||
[StringValue("sl")]
|
||||
Slovenia,
|
||||
|
||||
/// <summary>
|
||||
/// Spain
|
||||
/// </summary>
|
||||
[StringValue("es")]
|
||||
Spain,
|
||||
|
||||
/// <summary>
|
||||
/// Serbia
|
||||
/// </summary>
|
||||
[StringValue("sp")]
|
||||
Serbia,
|
||||
|
||||
/// <summary>
|
||||
/// El Salvador
|
||||
/// </summary>
|
||||
[StringValue("sv")]
|
||||
ElSalvador,
|
||||
|
||||
/// <summary>
|
||||
/// Syria
|
||||
/// </summary>
|
||||
[StringValue("sy")]
|
||||
Syria,
|
||||
|
||||
/// <summary>
|
||||
/// Taiwan
|
||||
/// </summary>
|
||||
[StringValue("tw")]
|
||||
Taiwan,
|
||||
|
||||
/// <summary>
|
||||
/// Thailand
|
||||
/// </summary>
|
||||
[StringValue("th")]
|
||||
Thailand,
|
||||
|
||||
/// <summary>
|
||||
/// Tunisia
|
||||
/// </summary>
|
||||
[StringValue("tn")]
|
||||
Tunisia,
|
||||
|
||||
/// <summary>
|
||||
/// Turkey
|
||||
/// </summary>
|
||||
[StringValue("tr")]
|
||||
Turkey,
|
||||
|
||||
/// <summary>
|
||||
/// Ukraine
|
||||
/// </summary>
|
||||
[StringValue("ua")]
|
||||
Ukraine,
|
||||
|
||||
/// <summary>
|
||||
/// United States
|
||||
/// </summary>
|
||||
[StringValue("us")]
|
||||
UnitedStates,
|
||||
|
||||
/// <summary>
|
||||
/// Vietnam
|
||||
/// </summary>
|
||||
[StringValue("vn")]
|
||||
Vietnam,
|
||||
|
||||
/// <summary>
|
||||
/// Yemen
|
||||
/// </summary>
|
||||
[StringValue("ye")]
|
||||
Yemen,
|
||||
|
||||
/// <summary>
|
||||
/// South Africa
|
||||
/// </summary>
|
||||
[StringValue("za")]
|
||||
SouthAfrica,
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Data Provider for connecting to Bing service.
|
||||
/// </summary>
|
||||
public class BingDataProvider : DataProviderBase<BingSearchConfig, BingResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Base Url for service.
|
||||
/// </summary>
|
||||
private const string BaseUrl = "http://www.bing.com";
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper around REST API for making data request.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSchema">Schema to use</typeparam>
|
||||
/// <param name="config">Query configuration.</param>
|
||||
/// <param name="maxRecords">Upper limit for records returned.</param>
|
||||
/// <param name="pageIndex">The zero-based index of the page that corresponds to the items to retrieve.</param>
|
||||
/// <param name="parser">IParser implementation for interpreting results.</param>
|
||||
/// <returns>Strongly typed list of results.</returns>
|
||||
protected override async Task<IEnumerable<TSchema>> GetDataAsync<TSchema>(BingSearchConfig config, int maxRecords, int pageIndex, Parsers.IParser<TSchema> parser)
|
||||
{
|
||||
var countryValue = config.Country.GetStringValue();
|
||||
var languageValue = config.Language.GetStringValue();
|
||||
var languageParameter = string.IsNullOrEmpty(languageValue) ? string.Empty : $"language:{languageValue}+";
|
||||
|
||||
if (string.IsNullOrEmpty(countryValue))
|
||||
{
|
||||
if (CultureInfo.CurrentCulture.IsNeutralCulture)
|
||||
{
|
||||
countryValue = BingCountry.None.GetStringValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
countryValue = CultureInfo.CurrentCulture.Name.Split('-')[1].ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
var locParameter = $"loc:{countryValue}+";
|
||||
var queryTypeParameter = string.Empty;
|
||||
|
||||
switch (config.QueryType)
|
||||
{
|
||||
case BingQueryType.Search:
|
||||
queryTypeParameter = string.Empty;
|
||||
break;
|
||||
|
||||
case BingQueryType.News:
|
||||
queryTypeParameter = "/news";
|
||||
break;
|
||||
}
|
||||
|
||||
var uri = new Uri($"{BaseUrl}{queryTypeParameter}/search?q={locParameter}{languageParameter}{WebUtility.UrlEncode(config.Query)}&format=rss&count={maxRecords}&first={(pageIndex * maxRecords) + (pageIndex > 0 ? 1 : 0)}");
|
||||
|
||||
using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri))
|
||||
{
|
||||
using (var response = await HttpClient.SendAsync(request).ConfigureAwait(false))
|
||||
{
|
||||
string data = response.Content == null ? null : await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode && !string.IsNullOrEmpty(data))
|
||||
{
|
||||
return parser.Parse(data);
|
||||
}
|
||||
|
||||
throw new RequestFailedException(response.StatusCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns parser implementation for specified configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">Query configuration.</param>
|
||||
/// <returns>Strongly typed parser.</returns>
|
||||
protected override Parsers.IParser<BingResult> GetDefaultParser(BingSearchConfig config)
|
||||
{
|
||||
return new BingParser();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check validity of configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">Query configuration.</param>
|
||||
protected override void ValidateConfig(BingSearchConfig config)
|
||||
{
|
||||
if (config?.Query == null)
|
||||
{
|
||||
throw new ConfigParameterNullException(nameof(config.Query));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Parsers.Rss;
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse Bing results into strong type.
|
||||
/// </summary>
|
||||
public class BingParser : Parsers.IParser<BingResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Take string data and parse into strong data type.
|
||||
/// </summary>
|
||||
/// <param name="data">String data.</param>
|
||||
/// <returns>Returns strong type.</returns>
|
||||
public IEnumerable<BingResult> Parse(string data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(data))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
RssParser rssParser = new RssParser();
|
||||
IEnumerable<RssSchema> syndicationItems = rssParser.Parse(data);
|
||||
return from r in syndicationItems
|
||||
select new BingResult
|
||||
{
|
||||
InternalID = r.InternalID,
|
||||
Title = r.Title,
|
||||
Summary = r.Summary,
|
||||
Link = r.FeedUrl,
|
||||
Published = r.PublishDate
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Search filter for search query.
|
||||
/// </summary>
|
||||
public enum BingQueryType
|
||||
{
|
||||
/// <summary>
|
||||
/// Search
|
||||
/// </summary>
|
||||
Search,
|
||||
|
||||
/// <summary>
|
||||
/// News
|
||||
/// </summary>
|
||||
News
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of the Bing result class.
|
||||
/// </summary>
|
||||
public class BingResult : Parsers.SchemaBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets title of the search result.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets summary of the search result.
|
||||
/// </summary>
|
||||
public string Summary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets link to the Search result.
|
||||
/// </summary>
|
||||
public string Link { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets date of publication.
|
||||
/// </summary>
|
||||
public DateTime Published { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Search query configuration.
|
||||
/// </summary>
|
||||
public class BingSearchConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets search query country.
|
||||
/// </summary>
|
||||
public BingCountry Country { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets search query language.
|
||||
/// </summary>
|
||||
public BingLanguage Language { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets search query.
|
||||
/// </summary>
|
||||
public string Query { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets search query type.
|
||||
/// </summary>
|
||||
public BingQueryType QueryType { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Collections;
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Bing
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for connecting to Bing.
|
||||
/// </summary>
|
||||
[Obsolete("The Bing Service will be removed in a future major release. Please use the Cognitive Services SDKs found at https://aka.ms/AA209h0.")]
|
||||
public class BingService : IDataService<BingDataProvider, BingResult, BingSearchConfig>, IIncrementalSource<BingResult>
|
||||
{
|
||||
private readonly BingSearchConfig _config;
|
||||
|
||||
private BingDataProvider bingDataProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BingService"/> class.
|
||||
/// </summary>
|
||||
public BingService()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BingService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="config">BingSearchConfig instance.</param>
|
||||
protected BingService(BingSearchConfig config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Private singleton field.
|
||||
/// </summary>
|
||||
private static BingService instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets public singleton property.
|
||||
/// </summary>
|
||||
public static BingService Instance => instance ?? (instance = new BingService());
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to an instance of the underlying data provider.
|
||||
/// </summary>
|
||||
public BingDataProvider Provider => bingDataProvider ?? (bingDataProvider = new BingDataProvider());
|
||||
|
||||
#if WINRT
|
||||
/// <summary>
|
||||
/// Gets an instance of <see cref="Uwp.IncrementalLoadingCollection{TSource, IType}"/> class that is able to load search data incrementally.
|
||||
/// </summary>
|
||||
/// <param name="config">BingSearchConfig instance.</param>
|
||||
/// <param name="maxRecords">Upper limit of records to return.</param>
|
||||
/// <returns>An instance of <see cref="Uwp.IncrementalLoadingCollection{TSource, IType}"/> class that is able to load search data incrementally.</returns>
|
||||
public static Uwp.IncrementalLoadingCollection<BingService, BingResult> GetAsIncrementalLoading(BingSearchConfig config, int maxRecords = 20)
|
||||
{
|
||||
var service = new BingService(config);
|
||||
return new Uwp.IncrementalLoadingCollection<BingService, BingResult>(service, maxRecords);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Request list data from service provider based upon a given config / query.
|
||||
/// </summary>
|
||||
/// <param name="config">BingSearchConfig instance.</param>
|
||||
/// <param name="maxRecords">Upper limit of records to return.</param>
|
||||
/// <param name="pageIndex">The zero-based index of the page that corresponds to the items to retrieve.</param>
|
||||
/// <returns>Strongly typed list of data returned from the service.</returns>
|
||||
public async Task<List<BingResult>> RequestAsync(BingSearchConfig config, int maxRecords = 20, int pageIndex = 0)
|
||||
{
|
||||
List<BingResult> queryResults = new List<BingResult>();
|
||||
|
||||
var results = await Provider.LoadDataAsync(config, maxRecords, pageIndex);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
queryResults.Add(result);
|
||||
}
|
||||
|
||||
return queryResults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves items based on <paramref name="pageIndex"/> and <paramref name="pageSize"/> arguments.
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">
|
||||
/// The zero-based index of the page that corresponds to the items to retrieve.
|
||||
/// </param>
|
||||
/// <param name="pageSize">
|
||||
/// The number of records to retrieve for the specified <paramref name="pageIndex"/>.
|
||||
/// </param>
|
||||
/// <param name="cancellationToken">
|
||||
/// Used to propagate notification that operation should be canceled.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Strongly typed list of data returned from the service.
|
||||
/// </returns>
|
||||
public async Task<IEnumerable<BingResult>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var queryResult = await RequestAsync(_config, pageSize, pageIndex);
|
||||
return queryResult.AsEnumerable();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -170,7 +170,7 @@ namespace Microsoft.Toolkit.Services.OneDrive.Uwp
|
|||
throw new ArgumentNullException(nameof(content));
|
||||
}
|
||||
|
||||
var uploadSessionUri = $"{_service.Provider.GraphProvider.BaseUrl}/drive/items/{_oneDriveStorageFolder.OneDriveItem.Id}:/{desiredName}:/createUploadSession";
|
||||
var uploadSessionUri = $"{_service.Provider.GraphProvider.BaseUrl}/me/drive/items/{_oneDriveStorageFolder.OneDriveItem.Id}:/{desiredName}:/createUploadSession";
|
||||
|
||||
var conflictBehavior = new OneDriveItemConflictBehavior { Item = new OneDriveConflictItem { ConflictBehavior = OneDriveHelper.TransformCollisionOptionToConflictBehavior(options.ToString()) } };
|
||||
|
||||
|
|
|
@ -21,13 +21,6 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
[JsonProperty("created_at")]
|
||||
public string CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets geographic data (latitude and longitude).
|
||||
/// </summary>
|
||||
[Obsolete("This member is deprecated by Twitter. Use Place and Coordinates instead.")]
|
||||
[JsonProperty("geo")]
|
||||
public TwitterGeoData GeoData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets item Id.
|
||||
/// </summary>
|
||||
|
@ -44,13 +37,6 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
set { _text = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets full 280-character tweet text.
|
||||
/// </summary>
|
||||
[Obsolete("This member has been deprecated by Twitter. Use Text instead.")]
|
||||
[JsonProperty("extended_tweet")]
|
||||
public TwitterExtended Extended { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets text of the tweet (280 characters).
|
||||
/// </summary>
|
||||
|
@ -166,5 +152,62 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
/// </summary>
|
||||
[JsonProperty("quoted_status_permalink")]
|
||||
public TwitterUrl QuotedStatusPermalink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets approximate count of tweets quoting tweet
|
||||
/// </summary>
|
||||
[JsonProperty("quote_count")]
|
||||
public int QuoteCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets number of replies to tweet
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Premium and Enterprise API access only
|
||||
/// </remarks>
|
||||
[JsonProperty("reply_count")]
|
||||
public int ReplyCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets number of times tweet has been retweeted
|
||||
/// </summary>
|
||||
[JsonProperty("retweet_count")]
|
||||
public int RetweetCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets number of times tweet has been liked
|
||||
/// </summary>
|
||||
[JsonProperty("favorite_count")]
|
||||
public int FavoriteCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not logged-in user has liked tweet
|
||||
/// </summary>
|
||||
[JsonProperty("favorited")]
|
||||
public bool Favorited { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not logged-in user has retweeted tweet
|
||||
/// </summary>
|
||||
[JsonProperty("retweeted")]
|
||||
public bool Retweeted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether URL in tweet has been flagged for sensitive content
|
||||
/// </summary>
|
||||
[JsonProperty("possibly_sensitive")]
|
||||
public bool Sensitive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets stream filter of tweet
|
||||
/// </summary>
|
||||
[JsonProperty("filter_level")]
|
||||
public string FilterLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets BCP 47 language identifier of tweet content
|
||||
/// </summary>
|
||||
[JsonProperty("lang")]
|
||||
public string Language { get; set; }
|
||||
}
|
||||
}
|
|
@ -267,20 +267,6 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
LoggedIn = false;
|
||||
}
|
||||
|
||||
#if WINRT
|
||||
/// <summary>
|
||||
/// Tweets a status update.
|
||||
/// </summary>
|
||||
/// <param name="tweet">Tweet text.</param>
|
||||
/// <param name="pictures">Pictures to attach to the tweet (up to 4).</param>
|
||||
/// <returns>Success or failure.</returns>
|
||||
[Obsolete("This method is deprecated in favour of TweetStatusAsync(string tweet, params Stream[] pictures). It will be removed in future version")]
|
||||
public async Task<bool> TweetStatusAsync(string tweet, params IRandomAccessStream[] pictures)
|
||||
{
|
||||
return await TweetStatusAsync(new TwitterStatus { Message = tweet }, pictures.Select(x => x.AsStream()).ToArray());
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Tweets a status update.
|
||||
/// </summary>
|
||||
|
@ -321,19 +307,6 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
return true;
|
||||
}
|
||||
|
||||
#if WINRT
|
||||
/// <summary>
|
||||
/// Publish a picture to Twitter user's medias.
|
||||
/// </summary>
|
||||
/// <param name="stream">Picture stream.</param>
|
||||
/// <returns>Media ID</returns>
|
||||
[Obsolete("This method is deprecated in favour of UploadPictureAsync(Stream stream). It will be removed in future version")]
|
||||
public Task<string> UploadPictureAsync(IRandomAccessStream stream)
|
||||
{
|
||||
return UploadPictureAsync(stream.AsStream());
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Publish a picture to Twitter user's medias.
|
||||
/// </summary>
|
||||
|
|
|
@ -18,6 +18,13 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
[JsonProperty("Hashtags")]
|
||||
public TwitterHashtag[] Hashtags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Symbols array of the tweet.
|
||||
/// This array will be empty if no Symbols are present.
|
||||
/// </summary>
|
||||
[JsonProperty("Symbols")]
|
||||
public TwitterSymbol[] Symbols { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Media array of the tweet.
|
||||
/// This array will not exist if no media is present.
|
||||
|
|
|
@ -260,21 +260,6 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
return await TweetStatusAsync(new TwitterStatus { Message = message });
|
||||
}
|
||||
|
||||
#if WINRT
|
||||
/// <summary>
|
||||
/// Post a Tweet with associated pictures.
|
||||
/// </summary>
|
||||
/// <param name="message">Tweet message.</param>
|
||||
/// <param name="pictures">Pictures to attach to the tweet (up to 4).</param>
|
||||
/// <returns>Returns success or failure of post request.</returns>
|
||||
[Obsolete("This method is deprecated in favour of TweetStatusAsync(string message, params Stream[] pictures). It will be removed in future version")]
|
||||
public async Task<bool> TweetStatusAsync(string message, params IRandomAccessStream[] pictures)
|
||||
{
|
||||
return await TweetStatusAsync(new TwitterStatus { Message = message }, pictures.Select(x => x.AsStream()).ToArray());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Post a Tweet with associated pictures.
|
||||
/// </summary>
|
||||
|
@ -286,21 +271,6 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
return await TweetStatusAsync(new TwitterStatus { Message = message }, pictures);
|
||||
}
|
||||
|
||||
#if WINRT
|
||||
/// <summary>
|
||||
/// Post a Tweet with associated pictures.
|
||||
/// </summary>
|
||||
/// <param name="status">The tweet information.</param>
|
||||
/// <param name="pictures">Pictures to attach to the tweet (up to 4).</param>
|
||||
/// <returns>Returns success or failure of post request.</returns>
|
||||
[Obsolete("This method is deprecated in favour of TweetStatusAsync(TwitterStatus status, params Stream[] pictures). It will be removed in future version")]
|
||||
public Task<bool> TweetStatusAsync(TwitterStatus status, params IRandomAccessStream[] pictures)
|
||||
{
|
||||
return TweetStatusAsync(status, pictures.Select(x => x.AsStream()).ToArray());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Post a Tweet with associated pictures.
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// 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.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.Toolkit.Services.Twitter
|
||||
{
|
||||
/// <summary>
|
||||
/// Twitter symbol object containing all stock symbols in a tweet.
|
||||
/// </summary>
|
||||
public class TwitterSymbol
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets indices of hashtag location in tweet string.
|
||||
/// </summary>
|
||||
[JsonProperty("indices")]
|
||||
public int[] Indices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hashtag text, excluding #.
|
||||
/// </summary>
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -192,12 +192,11 @@ namespace Microsoft.Toolkit.Services.Twitter
|
|||
[JsonProperty("default_profile_image")]
|
||||
public bool DefaultProfileImage { get; set; }
|
||||
|
||||
// <summary>
|
||||
// Gets or sets "withheld in" countries.
|
||||
// </summary>
|
||||
// commenting out because this is erroring when used, but this attribute is rarely used to begin with, so it's hard to repro long enough to debug
|
||||
// [JsonProperty("withheld_in_countries")]
|
||||
// public string WithheldInCountries { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets "withheld in" countries.
|
||||
/// </summary>
|
||||
[JsonProperty("withheld_in_countries")]
|
||||
public string[] WithheldInCountries { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets withheld scope (status or profile).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework><Title>Windows Community Toolkit UI</Title>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>Windows Community Toolkit UWP Platform Specific Analyzer</Title>
|
||||
<Description>This standard library provides analyzer and code fixer to ensure that version / platform specific code is well guarded. It is part of the Windows Community Toolkit.</Description>
|
||||
<PackageTags>UWP Toolkit Windows Platform Specific Analyzer</PackageTags>
|
||||
|
|
До Ширина: | Высота: | Размер: 1.9 MiB После Ширина: | Высота: | Размер: 4.1 MiB |
|
@ -40,12 +40,12 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Controls
|
|||
// Highlight Error Line
|
||||
XamlCodeRenderer.Decorations.Add(new IModelDeltaDecoration(
|
||||
range,
|
||||
new IModelDecorationOptions() { IsWholeLine = true, ClassName = _errorStyle, HoverMessage = new string[] { error.Message } }));
|
||||
new IModelDecorationOptions() { IsWholeLine = true, ClassName = _errorStyle, HoverMessage = new string[] { error.Message }.ToMarkdownString() }));
|
||||
|
||||
// Show Glyph Icon
|
||||
XamlCodeRenderer.Decorations.Add(new IModelDeltaDecoration(
|
||||
range,
|
||||
new IModelDecorationOptions() { IsWholeLine = true, GlyphMarginClassName = _errorIconStyle, GlyphMarginHoverMessage = new string[] { error.Message } }));
|
||||
new IModelDecorationOptions() { IsWholeLine = true, GlyphMarginClassName = _errorIconStyle, GlyphMarginHoverMessage = new string[] { error.Message }.ToMarkdownString() }));
|
||||
}
|
||||
|
||||
public void ClearErrors()
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
<Version>2.0.180916002-prerelease</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Monaco.Editor">
|
||||
<Version>0.6.0-alpha</Version>
|
||||
<Version>0.7.0-alpha</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StyleCop.Analyzers">
|
||||
<Version>1.0.2</Version>
|
||||
|
@ -175,7 +175,7 @@
|
|||
<Content Include="Assets\People\petri.png" />
|
||||
<Content Include="Assets\People\shen.png" />
|
||||
<Content Include="Assets\People\vlad.png" />
|
||||
<Content Include="Assets\Photos\Backgrounds\HERO.jpg" />
|
||||
<Content Include="Assets\Photos\Backgrounds\hero.jpg" />
|
||||
<Content Include="Assets\Photos\BigFourSummerHeat.jpg" />
|
||||
<Content Include="Assets\Photos\BisonBadlandsChillin.jpg" />
|
||||
<Content Include="Assets\Photos\ColumbiaRiverGorge.jpg" />
|
||||
|
@ -295,7 +295,6 @@
|
|||
<Content Include="SamplePages\BackdropSaturationBrush\BackdropSaturationBrush.png" />
|
||||
<Content Include="SamplePages\BackdropSepiaBrush\BackdropSepiaBrush.png" />
|
||||
<Content Include="SamplePages\BackgroundTaskHelper\BackgroundTaskHelper.png" />
|
||||
<Content Include="SamplePages\Bing Service\icon.png" />
|
||||
<Content Include="SamplePages\BluetoothLEHelper\BluetoothLEHelper.png" />
|
||||
<Content Include="SamplePages\BackdropBlurBrush\BackdropBlurBrush.png" />
|
||||
<Content Include="SamplePages\Blur\BlurBehavior.png" />
|
||||
|
@ -310,7 +309,6 @@
|
|||
<Content Include="SamplePages\FadeHeader\FadeHeaderBehavior.png" />
|
||||
<Content Include="SamplePages\Fade\FadeBehavior.png" />
|
||||
<Content Include="SamplePages\FocusTracker\FocusTracker.png" />
|
||||
<Content Include="SamplePages\Bing Service\BingCode.bind" />
|
||||
<Content Include="SamplePages\BladeView\BladeView.png" />
|
||||
<Content Include="SamplePages\Carousel\Carousel.png" />
|
||||
<Content Include="SamplePages\DropShadowPanel\DropShadowPanel.png" />
|
||||
|
@ -344,12 +342,10 @@
|
|||
<Content Include="SamplePages\Microsoft Graph Service\mslogo.png" />
|
||||
<Content Include="SamplePages\Microsoft Graph Service\user.png" />
|
||||
<Content Include="SamplePages\Microsoft Translator Service\TranslatorService.png" />
|
||||
<Content Include="SamplePages\NavigationViewStyles\NavigationViewStyles.png" />
|
||||
<Content Include="SamplePages\NetworkHelper\NetworkHelper.png" />
|
||||
<Content Include="SamplePages\Offset\OffsetBehavior.png" />
|
||||
<Content Include="SamplePages\Mouse\MouseCursor.png" />
|
||||
<Content Include="SamplePages\OneDrive Service\OneDriveLogo.png" />
|
||||
<Content Include="SamplePages\ParallaxService\Parallax.png" />
|
||||
<Content Include="SamplePages\RadialGauge\RadialGauge.png" />
|
||||
<Content Include="SamplePages\RadialGradientBrush\RadialGradientBrush.png" />
|
||||
<Content Include="SamplePages\RadialProgressBar\RadialProgressBar.png" />
|
||||
|
@ -367,11 +363,9 @@
|
|||
<Content Include="SamplePages\TileControl\Animations.png" />
|
||||
<Content Include="SamplePages\TileControl\TileControl.png" />
|
||||
<Content Include="SamplePages\PrintHelper\PrintHelper.png" />
|
||||
<Content Include="SamplePages\PullToRefreshListView\PullToRefreshListView.png" />
|
||||
<Content Include="SamplePages\ScrollHeader\ScrollHeader.png" />
|
||||
<Content Include="SamplePages\RangeSelector\RangeSelector.png" />
|
||||
<Content Include="SamplePages\RotatorTile\RotatorTile.png" />
|
||||
<Content Include="SamplePages\SlidableListItem\SlidableListItem.png" />
|
||||
<Content Include="SamplePages\Object Storage\ObjectStorage.png" />
|
||||
<Content Include="SamplePages\SurfaceDialTextbox\SurfaceDialTextbox.png" />
|
||||
<Content Include="SamplePages\TextBoxRegex\TextBoxRegex.png" />
|
||||
|
@ -395,11 +389,9 @@
|
|||
<Content Include="SamplePages\ImageEx\ImageExCode.bind" />
|
||||
<Content Include="SamplePages\Offset\OffsetBehaviorCode.bind" />
|
||||
<Content Include="SamplePages\Fade\FadeBehaviorCode.bind" />
|
||||
<Content Include="SamplePages\PullToRefreshListView\PullToRefreshListViewCode.bind" />
|
||||
<Content Include="SamplePages\RadialGauge\RadialGaugeCode.bind" />
|
||||
<Content Include="SamplePages\Rotate\RotateBehaviorCode.bind" />
|
||||
<Content Include="SamplePages\Scale\ScaleBehaviorCode.bind" />
|
||||
<Content Include="SamplePages\SlidableListItem\SlidableListItemCode.bind" />
|
||||
<Content Include="Assets\Photos\Photos.json" />
|
||||
<Content Include="Assets\Photos\OnlinePhotos.json" />
|
||||
<Content Include="SamplePages\RangeSelector\RangeSelectorCode.bind" />
|
||||
|
@ -439,7 +431,6 @@
|
|||
<Content Include="SamplePages\PrintHelper\PrintHelperCode.bind" />
|
||||
<Content Include="SamplePages\SystemInformation\SystemInformationCode.bind" />
|
||||
<Content Include="SamplePages\Connected Animations\ConnectedAnimationsCode.bind" />
|
||||
<Content Include="SamplePages\ParallaxService\ParallaxPage.bind" />
|
||||
<Content Include="SamplePages\Loading\LoadingCode.bind" />
|
||||
<Content Include="SamplePages\ReorderGridAnimation\ReorderGrid.bind" />
|
||||
<Content Include="SamplePages\Light\LightBehaviorCode.bind" />
|
||||
|
@ -477,7 +468,6 @@
|
|||
<Content Include="SamplePages\InAppNotification\InAppNotificationCode.bind" />
|
||||
<Content Include="SamplePages\InAppNotification\InAppNotificationXaml.bind" />
|
||||
<Content Include="SamplePages\ListViewExtensions\ListViewExtensionsCode.bind" />
|
||||
<Content Include="SamplePages\PullToRefreshListView\PullToRefreshListViewXaml.bind" />
|
||||
<Content Include="SamplePages\Implicit Animations\ImplicitAnimationsCode.bind" />
|
||||
<Content Include="SamplePages\DispatcherHelper\DispatcherHelperCode.bind" />
|
||||
<Content Include="SamplePages\TextToolbar\TextToolbar.bind" />
|
||||
|
@ -492,9 +482,6 @@
|
|||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="SamplePages\StaggeredPanel\StaggeredPanel.bind" />
|
||||
<Content Include="SamplePages\NavigationViewStyles\NavigationViewStylesXaml.bind">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="SamplePages\BackdropBlurBrush\BackdropBlurBrushXaml.bind" />
|
||||
<Content Include="SamplePages\BackdropInvertBrush\BackdropInvertBrushXaml.bind" />
|
||||
<Content Include="SamplePages\BackdropGammaTransferBrush\BackdropGammaTransferBrushXaml.bind">
|
||||
|
@ -690,9 +677,6 @@
|
|||
<Compile Include="SamplePages\Mouse\MouseCursorPage.xaml.cs">
|
||||
<DependentUpon>MouseCursorPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\NavigationViewStyles\NavigationViewStylesPage.xaml.cs">
|
||||
<DependentUpon>NavigationViewStylesPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\NetworkHelper\NetworkHelperPage.xaml.cs">
|
||||
<DependentUpon>NetworkHelperPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -760,9 +744,6 @@
|
|||
<Compile Include="Models\PropertyDescriptor\PropertyKind.cs" />
|
||||
<Compile Include="Models\PropertyDescriptor\PropertyDescriptor.cs" />
|
||||
<Compile Include="Common\BindableBase.cs" />
|
||||
<Compile Include="SamplePages\Bing Service\BingPage.xaml.cs">
|
||||
<DependentUpon>BingPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\BladeView\BladePage.xaml.cs">
|
||||
<DependentUpon>BladePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -832,9 +813,6 @@
|
|||
<Compile Include="SamplePages\ImageCache\ImageCachePage.xaml.cs">
|
||||
<DependentUpon>ImageCachePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\ParallaxService\ParallaxPage.xaml.cs">
|
||||
<DependentUpon>ParallaxPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\PrintHelper\PrintHelperPage.xaml.cs">
|
||||
<DependentUpon>PrintHelperPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -890,18 +868,12 @@
|
|||
<Compile Include="SamplePages\WeatherLiveTileAndToast\WeatherLiveTileAndToastPage.xaml.cs">
|
||||
<DependentUpon>WeatherLiveTileAndToastPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\PullToRefreshListView\PullToRefreshListViewPage.xaml.cs">
|
||||
<DependentUpon>PullToRefreshListViewPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\Rotate\RotateBehaviorPage.xaml.cs">
|
||||
<DependentUpon>RotateBehaviorPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\Scale\ScaleBehaviorPage.xaml.cs">
|
||||
<DependentUpon>ScaleBehaviorPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\SlidableListItem\SlidableListItemPage.xaml.cs">
|
||||
<DependentUpon>SlidableListItemPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\RadialGauge\RadialGaugePage.xaml.cs">
|
||||
<DependentUpon>RadialGaugePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -1109,10 +1081,6 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="SamplePages\NavigationViewStyles\NavigationViewStylesPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="SamplePages\RadialGradientBrush\RadialGradientBrushPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -1173,10 +1141,6 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\Bing Service\BingPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="SamplePages\BladeView\BladePage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -1269,10 +1233,6 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="SamplePages\ParallaxService\ParallaxPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\PrintHelper\PrintHelperPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -1345,10 +1305,6 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\PullToRefreshListView\PullToRefreshListViewPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\RadialGauge\RadialGaugePage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -1365,10 +1321,6 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\SlidableListItem\SlidableListItemPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\Weibo Service\WeiboPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
if (string.IsNullOrEmpty(SearchText.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var searchConfig = new BingSearchConfig
|
||||
{
|
||||
Country = BingCountry.UnitedStates,
|
||||
Language = BingLanguage.English,
|
||||
Query = SearchText.Text,
|
||||
QueryType = BingQueryType.Search
|
||||
};
|
||||
|
||||
// To perform a single call to get 50 items:
|
||||
ListView.ItemsSource = await BingService.Instance.RequestAsync(searchConfig, 50);
|
||||
|
||||
// To perform an incremental loading of search results (50 for each call):
|
||||
ListView.ItemsSource = BingService.GetAsIncrementalLoading(searchConfig, 50);
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.BingPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:bing="using:Microsoft.Toolkit.Services.Bing"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<DataTemplate x:Key="BingSchemaTemplate"
|
||||
x:DataType="bing:BingResult">
|
||||
<Grid Margin="0,5,10,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontWeight="Bold"
|
||||
Text="{x:Bind Title}"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{x:Bind Published}" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Text="{x:Bind Summary}"
|
||||
TextWrapping="Wrap" />
|
||||
<HyperlinkButton Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Content="{x:Bind Link}"
|
||||
NavigateUri="{x:Bind Link}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Margin="10"
|
||||
Orientation="Vertical">
|
||||
<TextBox x:Name="SearchText"
|
||||
Header="Request:"
|
||||
Text="UWP" />
|
||||
<ComboBox x:Name="CntryList"
|
||||
Margin="0,10,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Header="Country/Region:" />
|
||||
<ComboBox x:Name="Languages"
|
||||
Margin="0,10,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Header="Language:" />
|
||||
<ComboBox x:Name="QueryType"
|
||||
Margin="0,10,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Header="Type:" />
|
||||
<Button x:Name="SearchButton"
|
||||
Margin="0,10,0,0"
|
||||
Click="SearchButton_OnClick"
|
||||
Content="Search" />
|
||||
</StackPanel>
|
||||
<ListView x:Name="ListView"
|
||||
Grid.Row="1"
|
||||
ItemTemplate="{StaticResource BingSchemaTemplate}">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -1,71 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Services.Bing;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
public sealed partial class BingPage
|
||||
{
|
||||
public BingPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
QueryType.ItemsSource = new[] { "Bing Search", "Bing News" };
|
||||
QueryType.SelectedIndex = 0;
|
||||
CntryList.ItemsSource = Enum.GetValues(typeof(BingCountry)).Cast<BingCountry>().ToList();
|
||||
CntryList.SelectedItem = BingCountry.UnitedStates;
|
||||
Languages.ItemsSource = Enum.GetValues(typeof(BingLanguage)).Cast<BingLanguage>().ToList();
|
||||
Languages.SelectedItem = BingLanguage.English;
|
||||
}
|
||||
|
||||
private async void SearchButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!await Tools.CheckInternetConnectionAsync())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(SearchText.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BingCountry country = (BingCountry)(CntryList?.SelectedItem ?? BingCountry.UnitedStates);
|
||||
BingLanguage language = (BingLanguage)(Languages?.SelectedItem ?? BingLanguage.English);
|
||||
|
||||
BingQueryType queryType;
|
||||
switch (QueryType.SelectedIndex)
|
||||
{
|
||||
case 1:
|
||||
queryType = BingQueryType.News;
|
||||
break;
|
||||
default:
|
||||
queryType = BingQueryType.Search;
|
||||
break;
|
||||
}
|
||||
|
||||
var searchConfig = new BingSearchConfig
|
||||
{
|
||||
Country = country,
|
||||
Language = language,
|
||||
Query = SearchText.Text,
|
||||
QueryType = queryType
|
||||
};
|
||||
|
||||
// Gets an instance of BingService that is able to load search results incrementally.
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var collection = BingService.GetAsIncrementalLoading(searchConfig, 50);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
collection.OnStartLoading = async () => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SampleController.Current.DisplayWaitRing = true; });
|
||||
collection.OnEndLoading = async () => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SampleController.Current.DisplayWaitRing = false; });
|
||||
|
||||
ListView.ItemsSource = collection;
|
||||
}
|
||||
}
|
||||
}
|
До Ширина: | Высота: | Размер: 1.7 KiB |
|
@ -2,7 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.SampleApp.Data;
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls;
|
||||
|
@ -22,7 +21,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
private MenuFlyoutItem heightLowItem;
|
||||
private MenuFlyoutItem heightHighItem;
|
||||
private DataGridDataSource viewModel = new DataGridDataSource();
|
||||
private DataGridSortDirection? previousSortDirection = null;
|
||||
|
||||
public DataGridPage()
|
||||
{
|
||||
|
@ -31,12 +29,18 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
|
||||
public async void OnXamlRendered(FrameworkElement control)
|
||||
{
|
||||
if (dataGrid != null)
|
||||
{
|
||||
dataGrid.Sorting -= DataGrid_Sorting;
|
||||
dataGrid.LoadingRowGroup -= DataGrid_LoadingRowGroup;
|
||||
}
|
||||
|
||||
dataGrid = control.FindDescendantByName("dataGrid") as DataGrid;
|
||||
if (dataGrid != null)
|
||||
{
|
||||
dataGrid.ItemsSource = await viewModel.GetDataAsync();
|
||||
dataGrid.Sorting += DataGrid_Sorting;
|
||||
dataGrid.LoadingRowGroup += DataGrid_LoadingRowGroup;
|
||||
dataGrid.ItemsSource = await viewModel.GetDataAsync();
|
||||
|
||||
var comboBoxColumn = dataGrid.Columns.FirstOrDefault(x => x.Tag.Equals("Mountain")) as DataGridComboBoxColumn;
|
||||
if (comboBoxColumn != null)
|
||||
|
@ -45,30 +49,55 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
}
|
||||
}
|
||||
|
||||
if (groupButton != null)
|
||||
{
|
||||
groupButton.Click -= GroupButton_Click;
|
||||
}
|
||||
|
||||
groupButton = control.FindDescendantByName("groupButton") as AppBarButton;
|
||||
if (groupButton != null)
|
||||
{
|
||||
groupButton.Click += GroupButton_Click;
|
||||
}
|
||||
|
||||
if (rankLowItem != null)
|
||||
{
|
||||
rankLowItem.Click -= RankLowItem_Click;
|
||||
}
|
||||
|
||||
rankLowItem = control.FindName("rankLow") as MenuFlyoutItem;
|
||||
if (rankLowItem != null)
|
||||
{
|
||||
rankLowItem.Click += RankLowItem_Click;
|
||||
}
|
||||
|
||||
if (rankHighItem != null)
|
||||
{
|
||||
rankHighItem.Click -= RankHigh_Click;
|
||||
}
|
||||
|
||||
rankHighItem = control.FindName("rankHigh") as MenuFlyoutItem;
|
||||
if (rankHighItem != null)
|
||||
{
|
||||
rankHighItem.Click += RankHigh_Click;
|
||||
}
|
||||
|
||||
if (heightLowItem != null)
|
||||
{
|
||||
heightLowItem.Click -= HeightLow_Click;
|
||||
}
|
||||
|
||||
heightLowItem = control.FindName("heightLow") as MenuFlyoutItem;
|
||||
if (heightLowItem != null)
|
||||
{
|
||||
heightLowItem.Click += HeightLow_Click;
|
||||
}
|
||||
|
||||
if (heightHighItem != null)
|
||||
{
|
||||
heightHighItem.Click -= HeightHigh_Click;
|
||||
}
|
||||
|
||||
heightHighItem = control.FindName("heightHigh") as MenuFlyoutItem;
|
||||
if (heightHighItem != null)
|
||||
{
|
||||
|
@ -76,14 +105,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
}
|
||||
}
|
||||
|
||||
private void RankLowItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (dataGrid != null)
|
||||
{
|
||||
dataGrid.ItemsSource = viewModel.FilterData(DataGridDataSource.FilterOptions.Rank_Low);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGrid_LoadingRowGroup(object sender, DataGridRowGroupHeaderEventArgs e)
|
||||
{
|
||||
ICollectionViewGroup group = e.RowGroupHeader.CollectionViewGroup;
|
||||
|
@ -106,35 +127,37 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
{
|
||||
foreach (DataGridColumn dataGridColumn in dataGrid.Columns)
|
||||
{
|
||||
if (dataGridColumn.Tag != null && dataGridColumn.Tag.ToString() == previousSortedColumn)
|
||||
if (dataGridColumn.Tag != null && dataGridColumn.Tag.ToString() == previousSortedColumn &&
|
||||
(e.Column.Tag == null || previousSortedColumn != e.Column.Tag.ToString()))
|
||||
{
|
||||
if (e.Column.Tag == null || previousSortedColumn != e.Column.Tag.ToString())
|
||||
{
|
||||
dataGridColumn.SortDirection = null;
|
||||
previousSortDirection = null;
|
||||
}
|
||||
dataGridColumn.SortDirection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Column.Tag != null)
|
||||
{
|
||||
if ((e.Column.SortDirection == null || e.Column.SortDirection == DataGridSortDirection.Ascending)
|
||||
&& previousSortDirection != DataGridSortDirection.Ascending)
|
||||
if (e.Column.SortDirection == null || e.Column.SortDirection == DataGridSortDirection.Descending)
|
||||
{
|
||||
dataGrid.ItemsSource = viewModel.SortData(e.Column.Tag.ToString(), true);
|
||||
e.Column.SortDirection = DataGridSortDirection.Ascending;
|
||||
previousSortDirection = DataGridSortDirection.Ascending;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGrid.ItemsSource = viewModel.SortData(e.Column.Tag.ToString(), false);
|
||||
e.Column.SortDirection = DataGridSortDirection.Descending;
|
||||
previousSortDirection = DataGridSortDirection.Descending;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RankLowItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (dataGrid != null)
|
||||
{
|
||||
dataGrid.ItemsSource = viewModel.FilterData(DataGridDataSource.FilterOptions.Rank_Low);
|
||||
}
|
||||
}
|
||||
|
||||
private void RankHigh_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (dataGrid != null)
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<controls:MasterDetailsView ItemsSource="{Binding Emails}"
|
||||
<controls:MasterDetailsView BackButtonBehavior="Automatic"
|
||||
ItemsSource="{Binding Emails}"
|
||||
NoSelectionContent="Select an item to view"
|
||||
CompactModeThresholdWidth="720">
|
||||
<controls:MasterDetailsView.ItemTemplate>
|
||||
|
|
До Ширина: | Высота: | Размер: 2.5 KiB |
|
@ -1,25 +0,0 @@
|
|||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.NavigationViewStylesPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ex="using:Microsoft.Toolkit.Uwp.UI.Extensions"
|
||||
xmlns:contract5Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,5)"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI/Extensions/NavigationView/Styles/VSCodeActivityBarStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
<!-- Shallow Copy -->
|
||||
<contract5Present:NavigationView Style="{StaticResource VSCodeActivityBarStyle}"
|
||||
MenuItemContainerStyle="{StaticResource LargeIconNavigationViewItemStyle}"
|
||||
ex:NavigationViewExtensions.SelectedIndex="0"
|
||||
ex:NavigationViewExtensions.CollapseOnClick="True"/>
|
||||
</Page>
|
|
@ -1,18 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Extensions;
|
||||
using Windows.Foundation.Metadata;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
public sealed partial class NavigationViewStylesPage : Page
|
||||
{
|
||||
public NavigationViewStylesPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ex="using:Microsoft.Toolkit.Uwp.UI.Extensions"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI/Extensions/NavigationView/Styles/VSCodeActivityBarStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="48"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<NavigationView x:Name="NavMenu"
|
||||
Style="{StaticResource VSCodeActivityBarStyle}"
|
||||
MenuItemContainerStyle="{StaticResource LargeIconNavigationViewItemStyle}"
|
||||
ex:NavigationViewExtensions.SelectedIndex="0"
|
||||
ex:NavigationViewExtensions.CollapseOnClick="True">
|
||||
<NavigationView.MenuItems>
|
||||
<NavigationViewItem Content="Explorer" Tag="Some Text">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Source Control" Tag="Some Other Text">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Debug" Tag="More Text">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Extensions" Tag="Additional Text">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Search" Tag="Final Text">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
</NavigationView.MenuItems>
|
||||
|
||||
<Grid x:Name="ContentGrid" MinWidth="250"
|
||||
BorderBrush="DarkGray"
|
||||
BorderThickness="0,0,1,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0"
|
||||
Background="LightGray">
|
||||
<TextBlock x:Name="Header"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Margin="16,0,0,0"
|
||||
Foreground="Black"
|
||||
Text="{Binding ElementName=NavMenu, Path=SelectedItem.Content}" />
|
||||
</Border>
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="8"
|
||||
Text="{Binding ElementName=NavMenu, Path=SelectedItem.Tag}"/>
|
||||
</Grid>
|
||||
</NavigationView>
|
||||
<Grid Grid.Column="1" Margin="16">
|
||||
<TextBlock>Main App Content Area</TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
До Ширина: | Высота: | Размер: 1.2 KiB |
|
@ -1,28 +0,0 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:an="using:Microsoft.Toolkit.Uwp.UI.Animations"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Background="{ThemeResource Brush-Grey-05}">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<Image Source="ms-appx:///Assets/Photos/BigFourSummerHeat.jpg"
|
||||
an:ParallaxService.VerticalMultiplier="@[VerticalMultiplier:Slider:-.3:-1-1-.1]"/>
|
||||
<Border Background="{ThemeResource Brush-Grey-05}" Margin="32" Opacity="0.8">
|
||||
<TextBlock TextWrapping="WrapWholeWords" FontSize="20">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc fringilla ultrices est eu ornare. Suspendisse purus massa, iaculis in finibus dictum, gravida vel purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec vitae dolor imperdiet, vehicula enim quis, mollis tellus. Donec placerat diam sed est porttitor, venenatis semper mauris tempus. Sed placerat ipsum enim, quis porta nibh accumsan sit amet. Etiam tempus dapibus dolor, eget sollicitudin risus cursus eget. Vestibulum non rhoncus velit. Vestibulum volutpat, lacus quis laoreet accumsan, erat diam dignissim ligula, sit amet molestie purus erat eget tortor. Vestibulum posuere consequat libero, at fermentum tellus tempus eget. Curabitur viverra nisl a augue porta luctus.
|
||||
Duis sodales metus et purus finibus, at tincidunt felis porta. Fusce elementum ut diam ut sodales. Nunc eget varius lectus. Fusce nec rhoncus arcu. Nunc feugiat, nulla non luctus dapibus, justo odio tincidunt libero, mattis commodo sem nulla sed tellus. Aliquam ut condimentum est, id euismod turpis. Donec nec orci nulla. Suspendisse faucibus mollis sapien, ac congue nulla aliquet vel. In hac habitasse platea dictumst. Duis dapibus sem a ullamcorper vestibulum.
|
||||
Aliquam varius imperdiet tortor vitae elementum. Curabitur eget diam a neque blandit egestas. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus pulvinar laoreet ipsum ut scelerisque. Praesent eget molestie sem. Sed pretium suscipit orci, mollis interdum purus vestibulum vitae. Curabitur accumsan nec enim eu imperdiet. Fusce nec lectus mollis, laoreet odio vel, rhoncus nisi. Nulla mi neque, imperdiet nec diam et, tincidunt blandit metus. Quisque bibendum nisl a orci efficitur, sit amet volutpat nisi convallis. Sed lobortis ac lacus et volutpat. Nullam sodales porta nibh, eget semper augue fermentum sit amet. Phasellus sed nibh volutpat, fringilla ligula ut, lacinia dolor.
|
||||
Donec vulputate interdum mattis. Proin quam libero, ultricies quis sapien quis, feugiat consectetur sem. Fusce tincidunt mauris orci. Praesent ut mollis risus, in vestibulum dolor. Quisque nisi ex, vehicula ut libero at, pharetra feugiat velit. Sed mauris lorem, fermentum in nibh eu, ultrices ornare erat. Sed eu scelerisque felis. Suspendisse potenti. Donec ut odio sit amet lacus hendrerit commodo efficitur vel purus. Vestibulum pretium aliquam augue vel tincidunt. Quisque non urna a erat eleifend dapibus. Proin eget odio aliquet, hendrerit tellus sed, iaculis enim. In efficitur urna vel ante venenatis pellentesque. Curabitur nunc nisi, scelerisque at eros non, pellentesque mollis mauris.
|
||||
In sit amet dui ac mi scelerisque molestie ut vel ante. Mauris vitae interdum nisl. Vivamus ut mauris imperdiet, tincidunt odio non, dapibus massa. Nam a purus et justo porttitor viverra. Aenean consectetur massa a purus viverra auctor. Nunc pellentesque cursus orci non venenatis. Proin lacinia ullamcorper luctus. Quisque enim turpis, varius at arcu at, condimentum elementum odio. Vestibulum auctor aliquam arcu, et vulputate risus finibus id. Maecenas id erat vitae quam accumsan pretium nec ac orci. Cras massa eros, viverra id semper non, feugiat ut est. Fusce sodales mi a gravida ultrices. Nam congue dui quis imperdiet commodo.
|
||||
Ut nec ipsum a leo sollicitudin accumsan non nec velit. Cras luctus lorem sed ante accumsan tempus. Donec sollicitudin eleifend metus nec accumsan. Maecenas id purus nisl. Aliquam ut placerat augue, id tempus magna. Integer auctor tortor in augue placerat sollicitudin. Mauris facilisis fermentum massa, in rutrum dolor tempor id.
|
||||
Nam eu lobortis velit, ac lobortis nibh. Mauris facilisis urna mi, id iaculis leo tempor sit amet. Nullam fringilla, tellus vitae cursus fermentum, justo est consequat erat, faucibus malesuada erat orci eget enim. Curabitur condimentum dui quis scelerisque tincidunt. Vestibulum pretium bibendum neque, eget malesuada tellus lobortis ut. Phasellus in scelerisque nunc, sit amet eleifend massa. Nullam cursus orci et malesuada pretium. Quisque magna diam, semper nec auctor et, vulputate nec nisl. Cras feugiat accumsan urna, in vulputate erat convallis at. Pellentesque sapien metus, lacinia id nunc interdum, vehicula mollis urna.
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -1,19 +0,0 @@
|
|||
<Page
|
||||
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ParallaxPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:an="using:Microsoft.Toolkit.Uwp.UI.Animations"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- Shallow Copy-->
|
||||
<Grid Visibility="Collapsed">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<Image Source="ms-appx:///Assets/Photos/BigFourSummerHeat.jpg"
|
||||
an:ParallaxService.VerticalMultiplier="0.1"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -1,21 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.SampleApp.Models;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class ParallaxPage : Page
|
||||
{
|
||||
public ParallaxPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
До Ширина: | Высота: | Размер: 1.9 KiB |
|
@ -1,37 +0,0 @@
|
|||
/** XAML **/
|
||||
<controls:PullToRefreshListView x:Name="ListView"
|
||||
ItemsSource="{x:Bind _items}"
|
||||
RefreshIntentCanceled="ListView_RefreshIntentCanceled"
|
||||
RefreshIntentCanceledCommand="{x:Bind RefreshIntentCanceled}"
|
||||
RefreshRequested="ListView_RefreshCommand">
|
||||
|
||||
/** CSharp Code **/
|
||||
private readonly ObservableCollection<Item> _items;
|
||||
private DelegateCommand _refreshIntentCanceledCommand;
|
||||
|
||||
public PullToRefreshListViewPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_items = new ObservableCollection<Item>();
|
||||
AddItems();
|
||||
}
|
||||
|
||||
private void AddItems()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
_items.Insert(0, new Item { Title = "Item " + _items.Count });
|
||||
}
|
||||
}
|
||||
|
||||
private void ListView_RefreshCommand(object sender, EventArgs e)
|
||||
{
|
||||
AddItems();
|
||||
}
|
||||
|
||||
private void ListView_RefreshIntentCanceled(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private DelegateCommand RefreshIntentCanceled => _refreshIntentCanceledCommand ?? (_refreshIntentCanceledCommand = new DelegateCommand(
|
||||
() => { }));
|
|
@ -1,14 +0,0 @@
|
|||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.PullToRefreshListViewPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:data="using:Microsoft.Toolkit.Uwp.SampleApp.Models"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- Shallow Copy -->
|
||||
<Grid Visibility="Collapsed">
|
||||
<controls:PullToRefreshListView/>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -1,48 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using Microsoft.Toolkit.Uwp.SampleApp.Common;
|
||||
using Microsoft.Toolkit.Uwp.SampleApp.Models;
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls;
|
||||
using Microsoft.Toolkit.Uwp.UI.Extensions;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
public sealed partial class PullToRefreshListViewPage : IXamlRenderListener
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
private readonly ObservableCollection<Item> _items;
|
||||
|
||||
public PullToRefreshListViewPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_items = new ObservableCollection<Item>();
|
||||
AddItems();
|
||||
}
|
||||
|
||||
public void OnXamlRendered(FrameworkElement control)
|
||||
{
|
||||
var listView = control.FindChildByName("ListView") as PullToRefreshListView;
|
||||
listView.ItemsSource = _items;
|
||||
listView.RefreshRequested += ListView_RefreshCommand;
|
||||
}
|
||||
|
||||
private void AddItems()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
_items.Insert(0, new Item { Title = "Item " + _items.Count });
|
||||
}
|
||||
}
|
||||
|
||||
private void ListView_RefreshCommand(object sender, EventArgs e)
|
||||
{
|
||||
AddItems();
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:data="using:Microsoft.Toolkit.Uwp.SampleApp.Models"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<controls:PullToRefreshListView
|
||||
x:Name="ListView"
|
||||
MinWidth="200"
|
||||
Margin="24"
|
||||
HorizontalAlignment="Center"
|
||||
OverscrollLimit="@[OverscrollLimit:DoubleSlider:0.4:0-1]"
|
||||
PullThreshold="@[PullThreshold:Slider:100:50-300]"
|
||||
IsPullToRefreshWithMouseEnabled="@[IsPullToRefreshWithMouseEnabled:Bool:True]"
|
||||
UseRefreshContainerWhenPossible="@[UseRefreshContainerWhenPossible:Bool:True]">
|
||||
<controls:PullToRefreshListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock AutomationProperties.Name="{Binding Title}"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding Title}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
</DataTemplate>
|
||||
</controls:PullToRefreshListView.ItemTemplate>
|
||||
<controls:PullToRefreshListView.PullToRefreshContent>
|
||||
<TextBlock FontSize="16"
|
||||
Opacity="0.5"
|
||||
Text="Pull down to refresh data" />
|
||||
</controls:PullToRefreshListView.PullToRefreshContent>
|
||||
</controls:PullToRefreshListView>
|
||||
</Grid>
|
||||
</Page>
|
До Ширина: | Высота: | Размер: 4.3 KiB |
|
@ -1,83 +0,0 @@
|
|||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
|
||||
xmlns:data="using:Microsoft.Toolkit.Uwp.SampleApp.Models"
|
||||
x:Name="Page"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<local:RemoveItemCommand x:Key="RemoveItemCommand" />
|
||||
</ResourceDictionary>
|
||||
|
||||
<converters:BoolToObjectConverter x:Key="BoolToVisibilityConverter"
|
||||
FalseValue="Collapsed"
|
||||
TrueValue="Visible" />
|
||||
|
||||
<DataTemplate x:Key="EmailsItemTemplate">
|
||||
<controls:SlidableListItem
|
||||
MinWidth="300"
|
||||
MaxWidth="800"
|
||||
HorizontalAlignment="Stretch"
|
||||
DataContext="{Binding DataContext, ElementName=Page, Mode=OneWay}"
|
||||
ActivationWidth="@[Activation Width:Slider:100:50-250]"
|
||||
IsLeftCommandEnabled="@[Is LeftCommand Enabled:Bool:true]"
|
||||
IsOffsetLimited="@[Is Offset Limited:Bool:true]"
|
||||
IsPointerReleasedOnSwipingHandled="@[Is Pointer Released On Swiping Handled:Bool:false]"
|
||||
IsRightCommandEnabled="@[Is RightCommand Enabled:Bool:true]"
|
||||
LeftBackground="@[Left Background:Brush:SkyBlue]"
|
||||
LeftCommand="{Binding DataContext.ToggleFavorite, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
LeftForeground ="@[Left Foreground:Brush:White]"
|
||||
LeftIcon="@[Left Icon:Enum:Symbol.Favorite]"
|
||||
LeftLabel="@[Left Label:String:Set Favourite]"
|
||||
MouseSlidingEnabled="@[Mouse Sliding Enabled:Bool:true]"
|
||||
RightBackground="@[Right Background:Brush:OrangeRed]"
|
||||
RightCommand="{StaticResource RemoveItemCommand}"
|
||||
RightCommandParameter="{Binding DataContext, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
RightForeground ="@[Right Foreground:Brush:White]"
|
||||
RightIcon="@[Right Icon:Enum:Symbol.Delete]"
|
||||
RightLabel="@[Right Label:String:Delete]"
|
||||
UseSwipeControlWhenPossible="@[UseSwipeControlWhenPossible:Bool:True]">
|
||||
<Grid Height="110" Background="{ThemeResource Brush-Grey-04}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="48" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid x:Name="Checkmark"
|
||||
Background="SkyBlue"
|
||||
Visibility="{Binding DataContext.IsFavorite, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<SymbolIcon Foreground="White"
|
||||
Symbol="Accept" />
|
||||
</Grid>
|
||||
<TextBlock Grid.Column="1"
|
||||
Margin="12"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="16"
|
||||
FontWeight="Light"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding DataContext.Title, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
TextWrapping="NoWrap" />
|
||||
</Grid>
|
||||
</controls:SlidableListItem>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid Padding="24">
|
||||
<ListView x:Name="listView"
|
||||
HorizontalAlignment="Center"
|
||||
ItemTemplate="{StaticResource EmailsItemTemplate}"
|
||||
SelectionMode="None"
|
||||
IsItemClickEnabled="False">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
<Setter Property="Margin" Value="0,1"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -1,29 +0,0 @@
|
|||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.SlidableListItemPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:data="using:Microsoft.Toolkit.Uwp.SampleApp.Models"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- Shallow Copy -->
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<local:RemoveItemCommand x:Key="RemoveItemCommand" />
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
<ListView>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<controls:SlidableListItem>
|
||||
<Grid>
|
||||
</Grid>
|
||||
</controls:SlidableListItem>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Page>
|
|
@ -1,71 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Toolkit.Uwp.SampleApp.Models;
|
||||
using Microsoft.Toolkit.Uwp.UI.Extensions;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
public sealed partial class SlidableListItemPage : IXamlRenderListener
|
||||
{
|
||||
public static ObservableCollection<Item> Items { get; set; }
|
||||
|
||||
public SlidableListItemPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
Load();
|
||||
}
|
||||
|
||||
public void OnXamlRendered(FrameworkElement control)
|
||||
{
|
||||
var listView = control.FindChildByName("listView") as ListView;
|
||||
if (listView != null)
|
||||
{
|
||||
listView.ItemsSource = Items;
|
||||
}
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
// Reset items when revisiting sample.
|
||||
Items = new ObservableCollection<Item>();
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Items.Add(new Item() { Title = "Item " + i });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable SA1402 // File may only contain a single class
|
||||
internal class RemoveItemCommand : ICommand
|
||||
#pragma warning restore SA1402 // File may only contain a single class
|
||||
{
|
||||
event EventHandler ICommand.CanExecuteChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
}
|
||||
|
||||
remove
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
SlidableListItemPage.Items?.Remove(parameter as Item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Services.Twitter;
|
||||
using Microsoft.Toolkit.Uwp.Services;
|
||||
using Windows.Devices.Geolocation;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
|
|
|
@ -123,29 +123,6 @@
|
|||
"Icon": "/SamplePages/RadialProgressBar/RadialProgressBar.png",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/controls/RadialProgressBar.md"
|
||||
},
|
||||
{
|
||||
"Name": "SlidableListItem",
|
||||
"Type": "SlidableListItemPage",
|
||||
"About": "The SlidableListItem is deprecated and will be removed in a future major release. Please use the SwipeControl available in the Fall Creators Update.",
|
||||
"CodeUrl": "https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem",
|
||||
"XamlCodeFile": "SlidableListItemCode.bind",
|
||||
"Icon": "/SamplePages/SlidableListItem/SlidableListItem.png",
|
||||
"BadgeUpdateVersionRequired": "DEPRECATED",
|
||||
"DeprecatedWarning": "The SlidableListItem is deprecated and will be removed in a future major release. Please use the SwipeControl available in the Fall Creators Update.",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/controls/SlidableListItem.md"
|
||||
},
|
||||
{
|
||||
"Name": "PullToRefreshListView",
|
||||
"Type": "PullToRefreshListViewPage",
|
||||
"About": "The PullToRefreshListView will be removed in a future major release. Please use the RefreshContainer control available in the 1803 version of Windows.",
|
||||
"CodeUrl": "https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/PullToRefreshListView",
|
||||
"CodeFile": "PullToRefreshListViewCode.bind",
|
||||
"XamlCodeFile": "PullToRefreshListViewXaml.bind",
|
||||
"Icon": "/SamplePages/PullToRefreshListView/PullToRefreshListView.png",
|
||||
"BadgeUpdateVersionRequired": "DEPRECATED",
|
||||
"DeprecatedWarning": "The PullToRefreshListView will be removed in a future major release. Please use the RefreshContainer control available in the 1803 version of Windows.",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/controls/PullToRefreshListview.md"
|
||||
},
|
||||
{
|
||||
"Name": "RotatorTile",
|
||||
"Type": "RotatorTilePage",
|
||||
|
@ -395,12 +372,13 @@
|
|||
{
|
||||
"Name": "Light",
|
||||
"Type": "LightBehaviorPage",
|
||||
"About": "Light XAML elements using composition",
|
||||
"About": "The Light effect will be removed in a future major release",
|
||||
"BadgeUpdateVersionRequired": "DEPRECATED",
|
||||
"DeprecatedWarning": "The Light effect will be removed in a future major release",
|
||||
"CodeUrl": "https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors",
|
||||
"CodeFile": "LightBehaviorCode.bind",
|
||||
"XamlCodeFile": "LightBehaviorXaml.bind",
|
||||
"Icon": "/SamplePages/Light/LightBehavior.png",
|
||||
"BadgeUpdateVersionRequired": "Anniversary Update required",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/animations/Light.md"
|
||||
},
|
||||
{
|
||||
|
@ -413,17 +391,6 @@
|
|||
"Icon": "/SamplePages/FadeHeader/FadeHeaderBehavior.png",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/animations/FadeHeader.md"
|
||||
},
|
||||
{
|
||||
"Name": "ParallaxService",
|
||||
"Type": "ParallaxPage",
|
||||
"About": "The ParallaxService is deprecated and will be removed in a future major release. Please use the ParallaxView available in the Fall Creators Update.",
|
||||
"CodeUrl": "https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations",
|
||||
"XamlCodeFile": "ParallaxPage.bind",
|
||||
"Icon": "/SamplePages/ParallaxService/Parallax.png",
|
||||
"BadgeUpdateVersionRequired": "DEPRECATED",
|
||||
"DeprecatedWarning": "The ParallaxService is deprecated and will be removed in a future major release. Please use the ParallaxView available in the Fall Creators Update.",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/animations/ParallaxService.md"
|
||||
},
|
||||
{
|
||||
"Name": "ReorderGridAnimation",
|
||||
"Type": "ReorderGridPage",
|
||||
|
@ -522,17 +489,6 @@
|
|||
"Name": "Services",
|
||||
"Icon": "Icons/Services.png",
|
||||
"Samples": [
|
||||
{
|
||||
"Name": "Bing Service",
|
||||
"Type": "BingPage",
|
||||
"About": "The Bing Service will be removed in a future major release. Please use the Cognitive services SDKs found at https://aka.ms/AA209h0.",
|
||||
"CodeUrl": "https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.Services/Services/Bing",
|
||||
"CodeFile": "BingCode.bind",
|
||||
"Icon": "/SamplePages/Bing Service/icon.png",
|
||||
"BadgeUpdateVersionRequired": "DEPRECATED",
|
||||
"DeprecatedWarning": "The Bing Service will be removed in a future major release. Please use the Cognitive Services SDKs found at https://aka.ms/AA209h0.",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/services/Bing.md"
|
||||
},
|
||||
{
|
||||
"Name": "Facebook Service",
|
||||
"Type": "FacebookPage",
|
||||
|
@ -919,18 +875,6 @@
|
|||
"Icon": "/Assets/Helpers.png",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/extensions/StringExtensions.md"
|
||||
},
|
||||
{
|
||||
"Name": "NavigationViewStyles",
|
||||
"Type": "NavigationViewStylesPage",
|
||||
"XamlCodeFile": "NavigationViewStylesXaml.bind",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/WindowsCommunityToolkit/master/docs/extensions/NavigationView.md",
|
||||
"Icon": "/SamplePages/NavigationViewStyles/NavigationViewStyles.png",
|
||||
"About": "The NavigationView extension will be removed in a future major release.",
|
||||
"BadgeUpdateVersionRequired": "DEPRECATED",
|
||||
"DeprecatedWarning": "The NavigationView extension will be removed in a future major release.",
|
||||
"ApiCheck": "Windows.UI.Xaml.Controls.NavigationView",
|
||||
"CodeUrl": "https://github.com/Microsoft/UWPCommunitToolkit/tree/master/Microsoft.Toolkit.Uwp.UI/Extensions/NavigationView"
|
||||
},
|
||||
{
|
||||
"Name": "ScrollViewerExtensions",
|
||||
"Type": "ScrollViewerExtensionsPage",
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<winui:ParallaxView x:Name="Parallax"
|
||||
VerticalShift="50">
|
||||
<Image Stretch="UniformToFill"
|
||||
Source="Assets/Photos/Backgrounds/HERO.jpg"/>
|
||||
Source="Assets/Photos/Backgrounds/hero.jpg"/>
|
||||
</winui:ParallaxView>
|
||||
<Frame x:Name="NavigationFrame" />
|
||||
<Grid>
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
else
|
||||
{
|
||||
NavigationFrame.Navigate(typeof(SampleController), sample);
|
||||
TrackingManager.TrackEvent("sample", "navigation", sample.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
NavigationFrame.Navigating += NavigationFrame_Navigating;
|
||||
NavigationFrame.Navigated += NavigationFrameOnNavigated;
|
||||
NavView.BackRequested += NavView_BackRequested;
|
||||
|
||||
|
@ -107,12 +107,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
}
|
||||
}
|
||||
|
||||
private void NavigationFrame_Navigating(object sender, NavigatingCancelEventArgs navigationEventArgs)
|
||||
{
|
||||
var name = navigationEventArgs.SourcePageType.Name;
|
||||
TrackingManager.TrackPage(name);
|
||||
}
|
||||
|
||||
private void NavigationFrameOnNavigated(object sender, NavigationEventArgs navigationEventArgs)
|
||||
{
|
||||
NavView.IsBackEnabled = NavigationFrame.CanGoBack;
|
||||
|
|
|
@ -54,6 +54,14 @@
|
|||
"title": "UWP app samples",
|
||||
"url": "https://github.com/Microsoft/Windows-universal-samples"
|
||||
},
|
||||
{
|
||||
"title": "XAML Controls Gallery",
|
||||
"url": "https://www.microsoft.com/p/xaml-controls-gallery/9msvh128x2zt"
|
||||
},
|
||||
{
|
||||
"title": "Windows UI Library",
|
||||
"url": "https://docs.microsoft.com/uwp/toolkits/winui/"
|
||||
},
|
||||
{
|
||||
"title": "Windows Template Studio",
|
||||
"url": "https://github.com/microsoft/windowsTemplateStudio"
|
||||
|
@ -85,8 +93,8 @@
|
|||
"url": "https://github.com/hawkerm/monaco-editor-uwp"
|
||||
},
|
||||
{
|
||||
"title": "Background photo by Christoffer Engstr<74>m",
|
||||
"url": "https://unsplash.com/@christoffere"
|
||||
"title": "Background photo: Nordic sunset by Maarten Verstraete",
|
||||
"url": "https://unsplash.com/photos/yJiPvuyhO4s"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
@ -13,6 +14,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations.Behaviors
|
|||
/// </summary>
|
||||
/// <seealso cref="Microsoft.Toolkit.Uwp.UI.Animations.Behaviors.CompositionBehaviorBase" />
|
||||
/// <seealso cref="AnimationExtensions.IsLightingSupported"/>
|
||||
[Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")]
|
||||
|
||||
public class Light : CompositionBehaviorBase<FrameworkElement>
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
e.NavigationMode == Windows.UI.Xaml.Navigation.NavigationMode.Back &&
|
||||
ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.Animation.DirectConnectedAnimationConfiguration"))
|
||||
{
|
||||
animation.Configuration = new DirectConnectedAnimationConfiguration();
|
||||
UseDirectConnectedAnimationConfiguration(animation);
|
||||
}
|
||||
|
||||
_previousPageConnectedAnimationProps[props.Key] = props;
|
||||
|
@ -207,5 +207,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
|
||||
navigatedPage.Loaded += loadedHandler;
|
||||
}
|
||||
|
||||
private void UseDirectConnectedAnimationConfiguration(ConnectedAnimation animation)
|
||||
{
|
||||
animation.Configuration = new DirectConnectedAnimationConfiguration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
/// <param name="easingType">The easing function</param>
|
||||
/// <param name="easingMode">The easing mode</param>
|
||||
/// <returns>An animation set.</returns>
|
||||
[Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")]
|
||||
public static AnimationSet Light(
|
||||
this FrameworkElement associatedObject,
|
||||
double distance = 0d,
|
||||
|
@ -96,6 +97,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
/// <returns>
|
||||
/// An Animation Set.
|
||||
/// </returns>
|
||||
[Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")]
|
||||
public static AnimationSet Light(
|
||||
this AnimationSet animationSet,
|
||||
double distance = 0d,
|
||||
|
|
|
@ -1,153 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Animations.Expressions;
|
||||
using Microsoft.Toolkit.Uwp.UI.Extensions;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Hosting;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Animations
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the ability to create a parallax effect to items within a ScrollViewer or List control
|
||||
/// </summary>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public class ParallaxService
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the ParallaxService.VerticalMultiplier XAML attached property.
|
||||
/// </summary>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public static readonly DependencyProperty VerticalMultiplierProperty = DependencyProperty.RegisterAttached("VerticalMultiplier", typeof(double), typeof(ParallaxService), new PropertyMetadata(0d, OnMultiplierChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ParallaxService.HorizontalMultiplier attached property.
|
||||
/// </summary>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public static readonly DependencyProperty HorizontalMultiplierProperty = DependencyProperty.RegisterAttached("HorizontalMultiplier", typeof(double), typeof(ParallaxService), new PropertyMetadata(0d, OnMultiplierChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ParallaxService.VerticalMultiplier attached property value for the specified target element.
|
||||
/// </summary>
|
||||
/// <param name="element">The target element for the attached property value..</param>
|
||||
/// <returns>A value for how fast the parallax effect should scroll vertically.</returns>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public static double GetVerticalMultiplier(UIElement element)
|
||||
{
|
||||
return (double)element.GetValue(VerticalMultiplierProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the ParallaxService.VerticalMultiplier attached property value for the specified target element.
|
||||
/// </summary>
|
||||
/// <param name="element">The target element for the attached property value.</param>
|
||||
/// <param name="value">The value for how fast the parallax effect should scroll vertically.</param>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public static void SetVerticalMultiplier(UIElement element, double value)
|
||||
{
|
||||
element.SetValue(VerticalMultiplierProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ParallaxService.HorizontalMultiplier attached property value for the specified target element.
|
||||
/// </summary>
|
||||
/// <param name="element">The target element for the attached property value..</param>
|
||||
/// <returns>A value for how fast the parallax effect should scroll vertically.</returns>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public static double GetHorizontalMultiplier(UIElement element)
|
||||
{
|
||||
return (double)element.GetValue(HorizontalMultiplierProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the ParallaxService.HorizontalMultiplier attached property value for the specified target element.
|
||||
/// </summary>
|
||||
/// <param name="element">The target element for the attached property value.</param>
|
||||
/// <param name="value">The value for how fast the parallax effect should scroll horizontally.</param>
|
||||
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
|
||||
public static void SetHorizontalMultiplier(UIElement element, double value)
|
||||
{
|
||||
element.SetValue(HorizontalMultiplierProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ParallaxService.ScrollingElement XAML attached property.
|
||||
/// </summary>
|
||||
private static readonly DependencyProperty ScrollingElementProperty = DependencyProperty.RegisterAttached("ScrollingElement", typeof(ScrollViewer), typeof(ParallaxService), new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ParallaxService.ScrollingElementattached property value for the specified target element.
|
||||
/// </summary>
|
||||
/// <param name="element">The target element for the attached property value..</param>
|
||||
/// <returns>A <see cref="FrameworkElement"/> that is, or contains a ScrollViewer.</returns>
|
||||
private static ScrollViewer GetScrollingElement(UIElement element)
|
||||
{
|
||||
return (ScrollViewer)element.GetValue(ScrollingElementProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the ParallaxService.ScrollingElementattached property value for the specified target element.
|
||||
/// </summary>
|
||||
/// <param name="element">The target element for the attached property value.</param>
|
||||
/// <param name="value">The element that is, or contains a ScrollViewer.</param>
|
||||
private static void SetScrollingElement(UIElement element, ScrollViewer value)
|
||||
{
|
||||
element.SetValue(ScrollingElementProperty, value);
|
||||
}
|
||||
|
||||
private static void OnMultiplierChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var uiElement = (UIElement)d;
|
||||
var scrollViewer = GetScrollingElement(uiElement);
|
||||
if (scrollViewer == null)
|
||||
{
|
||||
var element = d as FrameworkElement;
|
||||
if (element != null)
|
||||
{
|
||||
scrollViewer = element.FindAscendant<ScrollViewer>();
|
||||
if (scrollViewer == null)
|
||||
{
|
||||
element.Loaded += OnElementLoaded;
|
||||
return;
|
||||
}
|
||||
|
||||
SetScrollingElement(uiElement, scrollViewer);
|
||||
}
|
||||
}
|
||||
|
||||
CreateParallax(uiElement, scrollViewer, (double)d.GetValue(HorizontalMultiplierProperty), (double)d.GetValue(VerticalMultiplierProperty));
|
||||
}
|
||||
|
||||
private static void OnElementLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var element = (FrameworkElement)sender;
|
||||
element.Loaded -= OnElementLoaded;
|
||||
|
||||
var scrollViewer = element.FindAscendant<ScrollViewer>();
|
||||
SetScrollingElement(element, scrollViewer);
|
||||
|
||||
CreateParallax(element, scrollViewer, (double)element.GetValue(HorizontalMultiplierProperty), (double)element.GetValue(VerticalMultiplierProperty));
|
||||
}
|
||||
|
||||
private static void CreateParallax(UIElement parallaxElement, ScrollViewer scroller, double horizontalMultiplier, double verticalMultiplier)
|
||||
{
|
||||
if ((parallaxElement == null) || (scroller == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CompositionPropertySet scrollerViewerManipulation = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scroller);
|
||||
var scrollPropSet = scrollerViewerManipulation.GetSpecializedReference<ManipulationPropertySetReferenceNode>();
|
||||
|
||||
var parallax = ExpressionFunctions.Vector3((float)horizontalMultiplier * scrollPropSet.Translation.X, (float)verticalMultiplier * scrollPropSet.Translation.Y, 0f);
|
||||
var expression = ExpressionFunctions.CreateTranslation(parallax);
|
||||
|
||||
Visual visual = ElementCompositionPreview.GetElementVisual(parallaxElement);
|
||||
visual.StartAnimation("TransformMatrix", expression);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -133,6 +133,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// 2 seconds delay used to hide the scroll bars for example when OS animations are turned off.
|
||||
private const int DATAGRID_noScrollBarCountdownMs = 2000;
|
||||
|
||||
// Used to work around double arithmetic rounding.
|
||||
private const double DATAGRID_roundingDelta = 0.0001;
|
||||
|
||||
// DataGrid Template Parts
|
||||
#if FEATURE_VALIDATION_SUMMARY
|
||||
private ValidationSummary _validationSummary;
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void Columns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems.Contains(this) && _owningGrid != null)
|
||||
if (this.OwningGrid == null && _owningGrid != null)
|
||||
{
|
||||
_owningGrid.Columns.CollectionChanged -= new NotifyCollectionChangedEventHandler(Columns_CollectionChanged);
|
||||
_owningGrid.CurrentCellChanged -= new EventHandler<EventArgs>(OwningGrid_CurrentCellChanged);
|
||||
|
|
|
@ -568,7 +568,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
DataGridFillerColumn fillerColumn = this.ColumnsInternal.FillerColumn;
|
||||
double totalColumnsWidth = this.ColumnsInternal.VisibleEdgedColumnsWidth;
|
||||
if (finalWidth > totalColumnsWidth && !DoubleUtil.AreClose(finalWidth, totalColumnsWidth))
|
||||
if (finalWidth - totalColumnsWidth > DATAGRID_roundingDelta)
|
||||
{
|
||||
fillerColumn.FillerWidth = finalWidth - totalColumnsWidth;
|
||||
}
|
||||
|
|
|
@ -4,18 +4,15 @@
|
|||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals;
|
||||
using Microsoft.Toolkit.Uwp.UI.Utilities;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
|
@ -46,8 +43,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Identifies the ItemsSource dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
|
||||
"ItemsSource", typeof(IEnumerable), typeof(DataGridComboBoxColumn), new PropertyMetadata(default(IEnumerable), OnItemSourcePropertyChanged));
|
||||
public static readonly DependencyProperty ItemsSourceProperty =
|
||||
DependencyProperty.Register(
|
||||
DATAGRIDCOMBOBOXCOLUMN_itemsSourceName,
|
||||
typeof(IEnumerable),
|
||||
typeof(DataGridComboBoxColumn),
|
||||
new PropertyMetadata(default(IEnumerable), OnItemSourcePropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a collection that is used to generate the content of the ComboBox while in editing mode.
|
||||
|
@ -67,8 +68,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Identifies the DisplayMemberPath dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DisplayMemberPathProperty = DependencyProperty.Register(
|
||||
"DisplayMemberPath", typeof(string), typeof(DataGridComboBoxColumn), new PropertyMetadata(default(string)));
|
||||
public static readonly DependencyProperty DisplayMemberPathProperty =
|
||||
DependencyProperty.Register(
|
||||
DATAGRIDCOMBOBOXCOLUMN_displayMemberPathName,
|
||||
typeof(string),
|
||||
typeof(DataGridComboBoxColumn),
|
||||
new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name or path of the property that is displayed in the ComboBox.
|
||||
|
@ -91,8 +96,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Identifies the FontFamily dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register(
|
||||
"FontFamily", typeof(FontFamily), typeof(DataGridComboBoxColumn), new PropertyMetadata(null, OnFontFamilyPropertyChanged));
|
||||
public static readonly DependencyProperty FontFamilyProperty =
|
||||
DependencyProperty.Register(
|
||||
DATAGRIDCOMBOBOXCOLUMN_fontFamilyName,
|
||||
typeof(FontFamily),
|
||||
typeof(DataGridComboBoxColumn),
|
||||
new PropertyMetadata(null, OnFontFamilyPropertyChanged));
|
||||
|
||||
private static void OnFontFamilyPropertyChanged(DependencyObject comboBoxColumnDependencyObject, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
|
@ -232,7 +241,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (DependencyProperty.UnsetValue != ReadLocalValue(DataGridComboBoxColumn.FontFamilyProperty))
|
||||
{
|
||||
comboBox.FontFamily = this.FontFamily;
|
||||
comboBox.FontFamily = FontFamily;
|
||||
}
|
||||
|
||||
if (_fontSize.HasValue)
|
||||
|
@ -257,7 +266,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
var item = args.AddedItems.FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
var newValue = !string.IsNullOrEmpty(this.DisplayMemberPath)
|
||||
var newValue = !string.IsNullOrEmpty(DisplayMemberPath)
|
||||
? item.GetType().GetProperty(Binding.Path.Path).GetValue(item)
|
||||
: item;
|
||||
|
||||
|
@ -267,7 +276,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
var dataType = this.OwningGrid.ItemsSource.GetItemType();
|
||||
var dataType = OwningGrid.ItemsSource.GetItemType();
|
||||
var newDataItem = Activator.CreateInstance(dataType);
|
||||
dataType.GetProperty(Binding.Path.Path).SetValue(newDataItem, newValue);
|
||||
dataItem = newDataItem;
|
||||
|
@ -287,9 +296,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
|
||||
{
|
||||
EnsureColumnBinding(dataItem);
|
||||
|
||||
EnsureDisplayMemberPathExists();
|
||||
|
||||
EnsureItemsSourceBinding();
|
||||
|
||||
var textBlockElement = new TextBlock
|
||||
|
@ -300,7 +307,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (DependencyProperty.UnsetValue != ReadLocalValue(DataGridComboBoxColumn.FontFamilyProperty))
|
||||
{
|
||||
textBlockElement.FontFamily = this.FontFamily;
|
||||
textBlockElement.FontFamily = FontFamily;
|
||||
}
|
||||
|
||||
if (_fontSize.HasValue)
|
||||
|
@ -320,11 +327,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
RefreshForeground(textBlockElement, (cell != null & cell.OwningRow != null) ? cell.OwningRow.ComputedForeground : null);
|
||||
|
||||
if (this.Binding != null && EnsureOwningGrid())
|
||||
if (Binding != null && EnsureOwningGrid())
|
||||
{
|
||||
if (string.IsNullOrEmpty(DisplayMemberPath))
|
||||
{
|
||||
textBlockElement.SetBinding(TextBlock.TextProperty, this.Binding);
|
||||
textBlockElement.SetBinding(TextBlock.TextProperty, Binding);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -388,7 +395,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontFamilyName)
|
||||
{
|
||||
textBlock.FontFamily = this.FontFamily;
|
||||
textBlock.FontFamily = FontFamily;
|
||||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontSizeName)
|
||||
{
|
||||
|
@ -396,11 +403,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontStyleName)
|
||||
{
|
||||
textBlock.FontStyle = this.FontStyle;
|
||||
textBlock.FontStyle = FontStyle;
|
||||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontWeightName)
|
||||
{
|
||||
textBlock.FontWeight = this.FontWeight;
|
||||
textBlock.FontWeight = FontWeight;
|
||||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_foregroundName)
|
||||
{
|
||||
|
@ -408,18 +415,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_itemsSourceName)
|
||||
{
|
||||
this.OwningGrid.OnColumnBindingChanged(this);
|
||||
OwningGrid.OnColumnBindingChanged(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.FontFamily != null)
|
||||
if (FontFamily != null)
|
||||
{
|
||||
textBlock.FontFamily = this.FontFamily;
|
||||
textBlock.FontFamily = FontFamily;
|
||||
}
|
||||
|
||||
SetTextFontSize(textBlock, TextBlock.FontSizeProperty);
|
||||
textBlock.FontStyle = this.FontStyle;
|
||||
textBlock.FontWeight = this.FontWeight;
|
||||
textBlock.FontStyle = FontStyle;
|
||||
textBlock.FontWeight = FontWeight;
|
||||
RefreshForeground(textBlock, computedRowForeground);
|
||||
}
|
||||
|
||||
|
@ -428,7 +435,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontFamilyName)
|
||||
{
|
||||
comboBox.FontFamily = this.FontFamily;
|
||||
comboBox.FontFamily = FontFamily;
|
||||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontSizeName)
|
||||
{
|
||||
|
@ -436,11 +443,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontStyleName)
|
||||
{
|
||||
comboBox.FontStyle = this.FontStyle;
|
||||
comboBox.FontStyle = FontStyle;
|
||||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_fontWeightName)
|
||||
{
|
||||
comboBox.FontWeight = this.FontWeight;
|
||||
comboBox.FontWeight = FontWeight;
|
||||
}
|
||||
else if (propertyName == DATAGRIDCOMBOBOXCOLUMN_foregroundName)
|
||||
{
|
||||
|
@ -448,14 +455,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
if (this.FontFamily != null)
|
||||
if (FontFamily != null)
|
||||
{
|
||||
comboBox.FontFamily = this.FontFamily;
|
||||
comboBox.FontFamily = FontFamily;
|
||||
}
|
||||
|
||||
SetTextFontSize(comboBox, ComboBox.FontSizeProperty);
|
||||
comboBox.FontStyle = this.FontStyle;
|
||||
comboBox.FontWeight = this.FontWeight;
|
||||
comboBox.FontStyle = FontStyle;
|
||||
comboBox.FontWeight = FontWeight;
|
||||
RefreshForeground(comboBox, computedRowForeground);
|
||||
}
|
||||
}
|
||||
|
@ -477,7 +484,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void RefreshForeground(ComboBox comboBox, Brush computedRowForeground)
|
||||
{
|
||||
if (this.Foreground == null)
|
||||
if (Foreground == null)
|
||||
{
|
||||
if (computedRowForeground != null)
|
||||
{
|
||||
|
@ -486,13 +493,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
comboBox.Foreground = this.Foreground;
|
||||
comboBox.Foreground = Foreground;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshForeground(TextBlock textBlock, Brush computedRowForeground)
|
||||
{
|
||||
if (this.Foreground == null)
|
||||
if (Foreground == null)
|
||||
{
|
||||
if (computedRowForeground != null)
|
||||
{
|
||||
|
@ -501,13 +508,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
textBlock.Foreground = this.Foreground;
|
||||
textBlock.Foreground = Foreground;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTextFontSize(DependencyObject textElement, DependencyProperty fontSizeProperty)
|
||||
{
|
||||
double newFontSize = this.FontSize;
|
||||
double newFontSize = FontSize;
|
||||
if (double.IsNaN(newFontSize))
|
||||
{
|
||||
textElement.ClearValue(fontSizeProperty);
|
||||
|
@ -520,11 +527,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private bool EnsureOwningGrid()
|
||||
{
|
||||
if (this.OwningGrid != null)
|
||||
if (OwningGrid != null)
|
||||
{
|
||||
if (this.OwningGrid != _owningGrid)
|
||||
if (OwningGrid != _owningGrid)
|
||||
{
|
||||
_owningGrid = this.OwningGrid;
|
||||
_owningGrid = OwningGrid;
|
||||
_owningGrid.Columns.CollectionChanged += new NotifyCollectionChangedEventHandler(Columns_CollectionChanged);
|
||||
_owningGrid.LoadingRow += OwningGrid_LoadingRow;
|
||||
_owningGrid.CellEditEnded += OwningGrid_CellEditEnded;
|
||||
}
|
||||
|
@ -545,11 +553,22 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
SetDisplayMemberPathValue(e.Row);
|
||||
}
|
||||
|
||||
private void Columns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (OwningGrid == null && _owningGrid != null)
|
||||
{
|
||||
_owningGrid.Columns.CollectionChanged -= new NotifyCollectionChangedEventHandler(Columns_CollectionChanged);
|
||||
_owningGrid.LoadingRow -= OwningGrid_LoadingRow;
|
||||
_owningGrid.CellEditEnded -= OwningGrid_CellEditEnded;
|
||||
_owningGrid = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDisplayMemberPathValue(DataGridRow row)
|
||||
{
|
||||
if (this.OwningGrid != null && !string.IsNullOrEmpty(DisplayMemberPath))
|
||||
if (OwningGrid != null && !string.IsNullOrEmpty(DisplayMemberPath))
|
||||
{
|
||||
var textBlock = this.GetCellContent(row) as TextBlock;
|
||||
var textBlock = GetCellContent(row) as TextBlock;
|
||||
if (textBlock != null)
|
||||
{
|
||||
var displayValue = GetDisplayValue(row.DataContext);
|
||||
|
@ -581,15 +600,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (!string.IsNullOrEmpty(Header as string))
|
||||
{
|
||||
throw new ArgumentException($"Binding for column \"{Header}\" is null. Ensure that the binding path has been set correctly.");
|
||||
throw DataGridError.DataGridComboBoxColumn.UnsetBinding(Header as string);
|
||||
}
|
||||
|
||||
throw new ArgumentException($"Binding for column of type {this.GetType()} is null. Ensure that the binding path has been set correctly.");
|
||||
throw DataGridError.DataGridComboBoxColumn.UnsetBinding(GetType());
|
||||
}
|
||||
|
||||
if (!dataItem?.GetType().GetProperties().Any(x => x.Name.Equals(this.Binding.Path.Path)) ?? false)
|
||||
if (!dataItem?.GetType().GetProperties().Any(x => x.Name.Equals(Binding.Path.Path)) ?? false)
|
||||
{
|
||||
throw new ArgumentException($"Binding path {this.Binding.Path.Path} could not be found in type {dataItem.GetType()}. Ensure that the binding path has been set correctly.");
|
||||
throw DataGridError.DataGridComboBoxColumn.UnknownBindingPath(Binding, dataItem.GetType());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,7 +620,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (ItemsSource != null && !type.GetProperties().Any(x => x.Name.Equals(DisplayMemberPath)))
|
||||
{
|
||||
throw new ArgumentException($"DisplayMemberPath \"{DisplayMemberPath}\" could not be found in type {type}. Ensure that the value has been set correctly and note that for built-in types DisplayMemberPath should not be used.");
|
||||
throw DataGridError.DataGridComboBoxColumn.UnknownDisplayMemberPath(DisplayMemberPath, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +633,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (item != null && !item.GetType().GetProperties().Any(y => y.Name.Equals(Binding.Path.Path)))
|
||||
{
|
||||
throw new ArgumentException($"The ItemsSource elements do not contain a property \"{Binding.Path.Path}\". Ensure that the binding path has been set correctly.");
|
||||
throw DataGridError.DataGridComboBoxColumn.UnknownItemsSourcePath(Binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
||||
{
|
||||
|
@ -179,6 +180,34 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
}
|
||||
}
|
||||
|
||||
public static class DataGridComboBoxColumn
|
||||
{
|
||||
public static ArgumentException UnsetBinding(string header)
|
||||
{
|
||||
return new ArgumentException(Format("Binding for column {0} is null. Ensure that the binding path has been set correctly.", header));
|
||||
}
|
||||
|
||||
public static ArgumentException UnsetBinding(Type type)
|
||||
{
|
||||
return new ArgumentException(Format("Binding for column of type {0} is null. Ensure that the binding path has been set correctly.", type.FullName));
|
||||
}
|
||||
|
||||
public static ArgumentException UnknownBindingPath(Binding binding, Type type)
|
||||
{
|
||||
return new ArgumentException(Format("Binding path {0} could not be found in type {1}. Ensure that the binding path has been set correctly.", binding.Path.Path, type.FullName));
|
||||
}
|
||||
|
||||
public static ArgumentException UnknownDisplayMemberPath(string displayMemberPath, Type type)
|
||||
{
|
||||
return new ArgumentException(Format("DisplayMemberPath {0} could not be found in type {1}. Ensure that the value has been set correctly and note that for built-in types DisplayMemberPath should not be used.", displayMemberPath, type.FullName));
|
||||
}
|
||||
|
||||
public static ArgumentException UnknownItemsSourcePath(Binding binding)
|
||||
{
|
||||
return new ArgumentException(Format("The ItemsSource elements do not contain a property {0}. Ensure that the binding path has been set correctly.", binding.Path.Path));
|
||||
}
|
||||
}
|
||||
|
||||
public static class DataGridTemplateColumn
|
||||
{
|
||||
public static TypeInitializationException MissingTemplateForType(Type type)
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public static readonly DependencyProperty FontFamilyProperty =
|
||||
DependencyProperty.Register(
|
||||
"FontFamily",
|
||||
DATAGRIDTEXTCOLUMN_fontFamilyName,
|
||||
typeof(FontFamily),
|
||||
typeof(DataGridTextColumn),
|
||||
new PropertyMetadata(null, OnFontFamilyPropertyChanged));
|
||||
|
@ -198,9 +198,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
RefreshForeground(textBox, (cell != null & cell.OwningRow != null) ? cell.OwningRow.ComputedForeground : null);
|
||||
|
||||
bool isDesignMode = Windows.ApplicationModel.DesignMode.DesignModeEnabled;
|
||||
|
||||
if (this.Binding != null || !isDesignMode)
|
||||
if (this.Binding != null)
|
||||
{
|
||||
textBox.SetBinding(this.BindingTarget, this.Binding);
|
||||
}
|
||||
|
@ -241,9 +239,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
RefreshForeground(textBlockElement, (cell != null & cell.OwningRow != null) ? cell.OwningRow.ComputedForeground : null);
|
||||
|
||||
bool isDesignMode = Windows.ApplicationModel.DesignMode.DesignModeEnabled;
|
||||
|
||||
if (this.Binding != null || !isDesignMode)
|
||||
if (this.Binding != null)
|
||||
{
|
||||
textBlockElement.SetBinding(TextBlock.TextProperty, this.Binding);
|
||||
}
|
||||
|
|
|
@ -116,13 +116,11 @@
|
|||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Common\ToolboxCategoryPaths.cs" />
|
||||
<Compile Include="PullToRefreshListViewMetadata.cs" />
|
||||
<Compile Include="RadialGaugeMetadata.cs" />
|
||||
<Compile Include="RadialProgressBarMetadata.cs" />
|
||||
<Compile Include="RangeSelectorMetadata.cs" />
|
||||
<Compile Include="RotatorTileMetadata.cs" />
|
||||
<Compile Include="ScrollHeaderMetadata.cs" />
|
||||
<Compile Include="SlidableListItemMetadata.cs" />
|
||||
<Compile Include="TextToolbarMetadata.cs" />
|
||||
<Compile Include="TileControlMetadata.cs" />
|
||||
<Compile Include="WrapPanelMetadata.cs" />
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common;
|
||||
using Microsoft.Windows.Design;
|
||||
using Microsoft.Windows.Design.Metadata;
|
||||
using Microsoft.Windows.Design.PropertyEditing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
|
||||
{
|
||||
internal class PullToRefreshListViewMetadata : AttributeTableBuilder
|
||||
{
|
||||
public PullToRefreshListViewMetadata()
|
||||
: base()
|
||||
{
|
||||
AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.PullToRefreshListView),
|
||||
b =>
|
||||
{
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.OverscrollLimit), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.PullThreshold), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.RefreshCommand),
|
||||
new EditorBrowsableAttribute(EditorBrowsableState.Advanced),
|
||||
new CategoryAttribute(Properties.Resources.CategoryCommon)
|
||||
);
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.RefreshIntentCanceledCommand),
|
||||
new EditorBrowsableAttribute(EditorBrowsableState.Advanced),
|
||||
new CategoryAttribute(Properties.Resources.CategoryCommon)
|
||||
);
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.RefreshIndicatorContent), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.PullToRefreshLabel), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.ReleaseToRefreshLabel), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.PullToRefreshContent), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.ReleaseToRefreshContent), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(PullToRefreshListView.IsPullToRefreshWithMouseEnabled), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common;
|
||||
using Microsoft.Windows.Design;
|
||||
using Microsoft.Windows.Design.Metadata;
|
||||
using Microsoft.Windows.Design.PropertyEditing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
|
||||
{
|
||||
internal class SlidableListItemMetadata : AttributeTableBuilder
|
||||
{
|
||||
public SlidableListItemMetadata()
|
||||
: base()
|
||||
{
|
||||
AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.SlidableListItem),
|
||||
b =>
|
||||
{
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.ExtraSwipeThreshold), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.IsOffsetLimited), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.IsRightCommandEnabled), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.IsLeftCommandEnabled), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.ActivationWidth), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.LeftIcon), new CategoryAttribute(Properties.Resources.CategoryAppearance));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.RightIcon), new CategoryAttribute(Properties.Resources.CategoryAppearance));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.LeftLabel), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.RightLabel), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.LeftForeground), new CategoryAttribute(Properties.Resources.CategoryBrush));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.RightForeground), new CategoryAttribute(Properties.Resources.CategoryBrush));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.LeftBackground), new CategoryAttribute(Properties.Resources.CategoryBrush));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.RightBackground), new CategoryAttribute(Properties.Resources.CategoryBrush));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.MouseSlidingEnabled), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.LeftCommand),
|
||||
new EditorBrowsableAttribute(EditorBrowsableState.Advanced),
|
||||
new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.RightCommand),
|
||||
new EditorBrowsableAttribute(EditorBrowsableState.Advanced),
|
||||
new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.SwipeStatus), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(nameof(SlidableListItem.IsPointerReleasedOnSwipingHandled), new CategoryAttribute(Properties.Resources.CategoryCommon));
|
||||
b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplateVisualState(Name = StateContentVisible, GroupName = GroupContent)]
|
||||
[TemplateVisualState(Name = StateContentCollapsed, GroupName = GroupContent)]
|
||||
[TemplatePart(Name = DismissButtonPart, Type = typeof(Button))]
|
||||
public sealed partial class InAppNotification : ContentControl
|
||||
public partial class InAppNotification : ContentControl
|
||||
{
|
||||
private InAppNotificationDismissKind _lastDismissKind;
|
||||
private DispatcherTimer _animationTimer = new DispatcherTimer();
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// An efficient and extensible control that can parse and render markdown.
|
||||
/// </summary>
|
||||
public sealed partial class MarkdownTextBlock : Control, ILinkRegister, IImageResolver, ICodeBlockResolver
|
||||
public partial class MarkdownTextBlock : Control, ILinkRegister, IImageResolver, ICodeBlockResolver
|
||||
{
|
||||
private long _fontSizePropertyToken;
|
||||
private long _backgroundPropertyToken;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// The behavior to use for navigating between the <see cref="MasterDetailsView"/> master and details views
|
||||
/// </summary>
|
||||
public enum BackButtonBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Automatically determine the best approach to use.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the back button controlled by <see cref="Windows.UI.Core.SystemNavigationManager"/> is already visible, the <see cref="MasterDetailsView"/> will hook into that button.
|
||||
/// If the new NavigationView provided by the Windows UI nuget package is used, the <see cref="MasterDetailsView"/> will enable and show that button.
|
||||
/// Otherwise the inline button is used.
|
||||
/// </remarks>
|
||||
Automatic,
|
||||
|
||||
/// <summary>
|
||||
/// Use a back button built into the <see cref="MasterDetailsView"/>
|
||||
/// </summary>
|
||||
Inline,
|
||||
|
||||
/// <summary>
|
||||
/// Use the system back button controlled by the <see cref="Windows.UI.Core.SystemNavigationManager"/>.
|
||||
/// </summary>
|
||||
System,
|
||||
|
||||
/// <summary>
|
||||
/// Do not enable any back buttons. Use this if you plan to handle all navigation or have your own back button in the application.
|
||||
/// </summary>
|
||||
Manual,
|
||||
}
|
||||
}
|
|
@ -65,6 +65,26 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
typeof(MasterDetailsView),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="DetailsHeader"/> dependency property.
|
||||
/// </summary>
|
||||
/// <returns>The identifier for the <see cref="DetailsHeader"/> dependency property.</returns>
|
||||
public static readonly DependencyProperty DetailsHeaderProperty = DependencyProperty.Register(
|
||||
nameof(DetailsHeader),
|
||||
typeof(object),
|
||||
typeof(MasterDetailsView),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="DetailsHeaderTemplate"/> dependency property.
|
||||
/// </summary>
|
||||
/// <returns>The identifier for the <see cref="DetailsHeaderTemplate"/> dependency property.</returns>
|
||||
public static readonly DependencyProperty DetailsHeaderTemplateProperty = DependencyProperty.Register(
|
||||
nameof(DetailsHeaderTemplate),
|
||||
typeof(DataTemplate),
|
||||
typeof(MasterDetailsView),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="MasterPaneWidth"/> dependency property.
|
||||
/// </summary>
|
||||
|
@ -134,13 +154,22 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
typeof(MasterDetailsView),
|
||||
new PropertyMetadata(720d, OnCompactModeThresholdWidthChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="BackButtonBehavior"/> dependancy property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BackButtonBehaviorProperty = DependencyProperty.Register(
|
||||
nameof(BackButtonBehavior),
|
||||
typeof(BackButtonBehavior),
|
||||
typeof(MasterDetailsView),
|
||||
new PropertyMetadata(BackButtonBehavior.System, OnBackButtonBehaviorChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected item.
|
||||
/// </summary>
|
||||
/// <returns>The selected item. The default is null.</returns>
|
||||
public object SelectedItem
|
||||
{
|
||||
get { return (object)GetValue(SelectedItemProperty); }
|
||||
get { return GetValue(SelectedItemProperty); }
|
||||
set { SetValue(SelectedItemProperty, value); }
|
||||
}
|
||||
|
||||
|
@ -171,7 +200,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </returns>
|
||||
public object MasterHeader
|
||||
{
|
||||
get { return (object)GetValue(MasterHeaderProperty); }
|
||||
get { return GetValue(MasterHeaderProperty); }
|
||||
set { SetValue(MasterHeaderProperty, value); }
|
||||
}
|
||||
|
||||
|
@ -187,6 +216,30 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
set { SetValue(MasterHeaderTemplateProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content for the details pane's header
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The content of the details pane's header. The default is null.
|
||||
/// </returns>
|
||||
public object DetailsHeader
|
||||
{
|
||||
get { return GetValue(DetailsHeaderProperty); }
|
||||
set { SetValue(DetailsHeaderProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DataTemplate used to display the content of the details pane's header.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The template that specifies the visualization of the details pane header object. The default is null.
|
||||
/// </returns>
|
||||
public DataTemplate DetailsHeaderTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(DetailsHeaderTemplateProperty); }
|
||||
set { SetValue(DetailsHeaderTemplateProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the master pane when the view is expanded.
|
||||
/// </summary>
|
||||
|
@ -205,7 +258,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public object NoSelectionContent
|
||||
{
|
||||
get { return (object)GetValue(NoSelectionContentProperty); }
|
||||
get { return GetValue(NoSelectionContentProperty); }
|
||||
set { SetValue(NoSelectionContentProperty, value); }
|
||||
}
|
||||
|
||||
|
@ -258,6 +311,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
set { SetValue(CompactModeThresholdWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the behavior to use for the back button
|
||||
/// </summary>
|
||||
/// <returns>The current BackButtonBehavior. The default is System.</returns>
|
||||
public BackButtonBehavior BackButtonBehavior
|
||||
{
|
||||
get { return (BackButtonBehavior)GetValue(BackButtonBehaviorProperty); }
|
||||
set { SetValue(BackButtonBehaviorProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a function for mapping the selected item to a different model.
|
||||
/// This new model will be the DataContext of the Details area.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Extensions;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.UI.Core;
|
||||
|
@ -28,6 +29,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
private const string PartDetailsPresenter = "DetailsPresenter";
|
||||
private const string PartDetailsPanel = "DetailsPanel";
|
||||
private const string PartBackButton = "MasterDetailsBackButton";
|
||||
private const string PartHeaderContentPresenter = "HeaderContentPresenter";
|
||||
private const string NarrowState = "NarrowState";
|
||||
private const string WideState = "WideState";
|
||||
|
@ -38,9 +40,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private const string NoSelectionNarrowState = "NoSelectionNarrow";
|
||||
private const string NoSelectionWideState = "NoSelectionWide";
|
||||
|
||||
private AppViewBackButtonVisibility _previousBackButtonVisibility;
|
||||
private AppViewBackButtonVisibility? _previousSystemBackButtonVisibility;
|
||||
private bool _previousNavigationViewBackEnabled;
|
||||
|
||||
// Int used because the underlying type is an enum, but we don't have access to the enum
|
||||
private int _previousNavigationViewBackVisibilty;
|
||||
private ContentPresenter _detailsPresenter;
|
||||
private VisualStateGroup _selectionStateGroup;
|
||||
private Button _inlineBackButton;
|
||||
private object _navigationView;
|
||||
private Frame _frame;
|
||||
|
||||
/// <summary>
|
||||
|
@ -63,6 +71,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
if (_inlineBackButton != null)
|
||||
{
|
||||
_inlineBackButton.Click -= OnInlineBackButtonClicked;
|
||||
}
|
||||
|
||||
_inlineBackButton = (Button)GetTemplateChild(PartBackButton);
|
||||
if (_inlineBackButton != null)
|
||||
{
|
||||
_inlineBackButton.Click += OnInlineBackButtonClicked;
|
||||
}
|
||||
|
||||
_detailsPresenter = (ContentPresenter)GetTemplateChild(PartDetailsPresenter);
|
||||
SetDetailsContent();
|
||||
|
||||
|
@ -131,6 +150,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
((MasterDetailsView)d).HandleStateChanges();
|
||||
}
|
||||
|
||||
private static void OnBackButtonBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var view = (MasterDetailsView)d;
|
||||
view.SetBackButtonVisibility();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the MasterCommandBar changes.
|
||||
/// </summary>
|
||||
|
@ -152,6 +177,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
_frame.Navigating -= OnFrameNavigating;
|
||||
}
|
||||
|
||||
_navigationView = this.FindAscendants().FirstOrDefault(p => p.GetType().FullName == "Microsoft.UI.Xaml.Controls.NavigationView");
|
||||
_frame = this.FindAscendant<Frame>();
|
||||
if (_frame != null)
|
||||
{
|
||||
|
@ -197,6 +223,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
private void OnInlineBackButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
|
||||
private void HandleStateChanges()
|
||||
{
|
||||
UpdateView(true);
|
||||
|
@ -255,8 +286,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Sets the back button visibility based on the current visual state and selected item
|
||||
/// </summary>
|
||||
private void SetBackButtonVisibility(MasterDetailsViewState previousState)
|
||||
private void SetBackButtonVisibility(MasterDetailsViewState? previousState = null)
|
||||
{
|
||||
const int backButtonVisible = 1;
|
||||
|
||||
if (DesignMode.DesignModeEnabled)
|
||||
{
|
||||
return;
|
||||
|
@ -264,15 +297,65 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (ViewState == MasterDetailsViewState.Details)
|
||||
{
|
||||
var navigationManager = SystemNavigationManager.GetForCurrentView();
|
||||
_previousBackButtonVisibility = navigationManager.AppViewBackButtonVisibility;
|
||||
if ((BackButtonBehavior == BackButtonBehavior.Inline) && (_inlineBackButton != null))
|
||||
{
|
||||
_inlineBackButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
else if (BackButtonBehavior == BackButtonBehavior.Automatic)
|
||||
{
|
||||
// Continue to support the system back button if it is being used
|
||||
var navigationManager = SystemNavigationManager.GetForCurrentView();
|
||||
if (navigationManager.AppViewBackButtonVisibility == AppViewBackButtonVisibility.Visible)
|
||||
{
|
||||
// Setting this indicates that the system back button is being used
|
||||
_previousSystemBackButtonVisibility = navigationManager.AppViewBackButtonVisibility;
|
||||
}
|
||||
else if ((_navigationView == null) || (_frame == null))
|
||||
{
|
||||
// We can only use the new NavigationView if we also have a Frame
|
||||
// If there is no frame we have to use the inline button
|
||||
_inlineBackButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNavigationViewBackButtonState(backButtonVisible, true);
|
||||
}
|
||||
}
|
||||
else if (BackButtonBehavior != BackButtonBehavior.Manual)
|
||||
{
|
||||
var navigationManager = SystemNavigationManager.GetForCurrentView();
|
||||
_previousSystemBackButtonVisibility = navigationManager.AppViewBackButtonVisibility;
|
||||
|
||||
navigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
|
||||
navigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
|
||||
}
|
||||
}
|
||||
else if (previousState == MasterDetailsViewState.Details)
|
||||
{
|
||||
// Make sure we show the back button if the stack can navigate back
|
||||
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = _previousBackButtonVisibility;
|
||||
if ((BackButtonBehavior == BackButtonBehavior.Inline) && (_inlineBackButton != null))
|
||||
{
|
||||
_inlineBackButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (BackButtonBehavior == BackButtonBehavior.Automatic)
|
||||
{
|
||||
if (_previousSystemBackButtonVisibility.HasValue == false)
|
||||
{
|
||||
if ((_navigationView == null) || (_frame == null))
|
||||
{
|
||||
_inlineBackButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNavigationViewBackButtonState(_previousNavigationViewBackVisibilty, _previousNavigationViewBackEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_previousSystemBackButtonVisibility.HasValue)
|
||||
{
|
||||
// Make sure we show the back button if the stack can navigate back
|
||||
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = _previousSystemBackButtonVisibility.Value;
|
||||
_previousSystemBackButtonVisibility = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,6 +401,24 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
VisualStateManager.GoToState(this, state, animate);
|
||||
}
|
||||
|
||||
private void SetNavigationViewBackButtonState(int visible, bool enabled)
|
||||
{
|
||||
var navType = _navigationView.GetType();
|
||||
var visibleProperty = navType.GetProperty("IsBackButtonVisible");
|
||||
if (visibleProperty != null)
|
||||
{
|
||||
_previousNavigationViewBackVisibilty = (int)visibleProperty.GetValue(_navigationView);
|
||||
visibleProperty.SetValue(_navigationView, visible);
|
||||
}
|
||||
|
||||
var enabledProperty = navType.GetProperty("IsBackEnabled");
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
_previousNavigationViewBackEnabled = (bool)enabledProperty.GetValue(_navigationView);
|
||||
enabledProperty.SetValue(_navigationView, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDetailsContent()
|
||||
{
|
||||
if (_detailsPresenter != null)
|
||||
|
|
|
@ -54,14 +54,33 @@
|
|||
ContentTemplate="{TemplateBinding NoSelectionContentTemplate}" />
|
||||
<Grid x:Name="SelectionDetailsPanel">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="MasterDetailsBackButton"
|
||||
Background="Transparent"
|
||||
Height="44"
|
||||
Width="48"
|
||||
Visibility="Collapsed">
|
||||
<SymbolIcon Symbol="Back"/>
|
||||
</Button>
|
||||
<ContentPresenter x:Name="DetailsHeaderPresenter"
|
||||
Content="{TemplateBinding DetailsHeader}"
|
||||
ContentTemplate="{TemplateBinding DetailsHeaderTemplate}"
|
||||
Grid.Column="1"/>
|
||||
</Grid>
|
||||
<ContentPresenter x:Name="DetailsPresenter"
|
||||
Background="{TemplateBinding Background}"
|
||||
ContentTemplate="{TemplateBinding DetailsTemplate}">
|
||||
Background="{TemplateBinding Background}"
|
||||
ContentTemplate="{TemplateBinding DetailsTemplate}"
|
||||
Grid.Row="1">
|
||||
</ContentPresenter>
|
||||
<Grid x:Name="DetailsCommandBarPanel" Grid.Row="1"></Grid>
|
||||
<Grid x:Name="DetailsCommandBarPanel" Grid.Row="2"></Grid>
|
||||
<Grid.RenderTransform>
|
||||
<TranslateTransform x:Name="DetailsPresenterTransform" />
|
||||
</Grid.RenderTransform>
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplatePart(Name = "AnchorCanvas", Type = typeof(Canvas))]
|
||||
[TemplatePart(Name = "OrbitGrid", Type = typeof(Grid))]
|
||||
[TemplatePart(Name = "CenterContent", Type = typeof(ContentPresenter))]
|
||||
public sealed class OrbitView : ItemsControl
|
||||
public class OrbitView : ItemsControl
|
||||
{
|
||||
private const double AnimationDuration = 200;
|
||||
|
||||
|
|
|
@ -1,899 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Toolkit.Uwp.UI.Extensions;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Metadata;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension of ListView that allows "Pull To Refresh" on touch devices
|
||||
/// </summary>
|
||||
[TemplatePart(Name = PartRoot, Type = typeof(Border))]
|
||||
[TemplatePart(Name = PartScroller, Type = typeof(ScrollViewer))]
|
||||
[TemplatePart(Name = PartContentTransform, Type = typeof(CompositeTransform))]
|
||||
[TemplatePart(Name = PartScrollerContent, Type = typeof(Grid))]
|
||||
[TemplatePart(Name = PartRefreshIndicatorBorder, Type = typeof(Border))]
|
||||
[TemplatePart(Name = PartIndicatorTransform, Type = typeof(CompositeTransform))]
|
||||
[TemplatePart(Name = PartDefaultIndicatorContent, Type = typeof(TextBlock))]
|
||||
[TemplatePart(Name = PullAndReleaseIndicatorContent, Type = typeof(ContentPresenter))]
|
||||
[Obsolete("The PullToRefreshListView will be removed in a future major release. Please use the RefreshContainer control available in the 1803 version of Windows")]
|
||||
public class PullToRefreshListView : ListView
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="OverscrollLimit"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty OverscrollLimitProperty =
|
||||
DependencyProperty.Register(nameof(OverscrollLimit), typeof(double), typeof(PullToRefreshListView), new PropertyMetadata(0.4, OverscrollLimitPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="PullThreshold"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PullThresholdProperty =
|
||||
DependencyProperty.Register(nameof(PullThreshold), typeof(double), typeof(PullToRefreshListView), new PropertyMetadata(100.0));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RefreshCommand"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RefreshCommandProperty =
|
||||
DependencyProperty.Register(nameof(RefreshCommand), typeof(ICommand), typeof(PullToRefreshListView), new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RefreshIntentCanceledCommand"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RefreshIntentCanceledCommandProperty =
|
||||
DependencyProperty.Register(nameof(RefreshIntentCanceledCommand), typeof(ICommand), typeof(PullToRefreshListView), new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RefreshIndicatorContent"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RefreshIndicatorContentProperty =
|
||||
DependencyProperty.Register(nameof(RefreshIndicatorContent), typeof(object), typeof(PullToRefreshListView), new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="PullToRefreshLabel"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PullToRefreshLabelProperty =
|
||||
DependencyProperty.Register(nameof(PullToRefreshLabel), typeof(object), typeof(PullToRefreshListView), new PropertyMetadata("Pull To Refresh", OnPullToRefreshLabelChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ReleaseToRefreshLabel"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ReleaseToRefreshLabelProperty =
|
||||
DependencyProperty.Register(nameof(ReleaseToRefreshLabel), typeof(object), typeof(PullToRefreshListView), new PropertyMetadata("Release to Refresh", OnReleaseToRefreshLabelChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="PullToRefreshContent"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PullToRefreshContentProperty =
|
||||
DependencyProperty.Register(nameof(PullToRefreshContent), typeof(object), typeof(PullToRefreshListView), new PropertyMetadata("Pull To Refresh"));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ReleaseToRefreshContent"/> property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ReleaseToRefreshContentProperty =
|
||||
DependencyProperty.Register(nameof(ReleaseToRefreshContent), typeof(object), typeof(PullToRefreshListView), new PropertyMetadata("Release to Refresh"));
|
||||
|
||||
/// <summary>
|
||||
/// IsPullToRefreshWithMouseEnabled Dependency Property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsPullToRefreshWithMouseEnabledProperty =
|
||||
DependencyProperty.Register(nameof(IsPullToRefreshWithMouseEnabled), typeof(bool), typeof(PullToRefreshListView), new PropertyMetadata(false));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="UseRefreshContainerWhenPossible"/> dependency property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty UseRefreshContainerWhenPossibleProperty =
|
||||
DependencyProperty.Register(nameof(UseRefreshContainerWhenPossible), typeof(bool), typeof(PullToRefreshListView), new PropertyMetadata(false, OnUseRefreshContainerWhenPossibleChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether <see cref="RefreshContainer"/> is supported
|
||||
/// </summary>
|
||||
public static bool IsRefreshContainerSupported { get; } = ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.RefreshContainer");
|
||||
|
||||
private const string PartRoot = "Root";
|
||||
private const string PartScroller = "ScrollViewer";
|
||||
private const string PartContentTransform = "ContentTransform";
|
||||
private const string PartScrollerContent = "ItemsPresenter";
|
||||
private const string PartRefreshIndicatorBorder = "RefreshIndicator";
|
||||
private const string PartIndicatorTransform = "RefreshIndicatorTransform";
|
||||
private const string PartDefaultIndicatorContent = "DefaultIndicatorContent";
|
||||
private const string PullAndReleaseIndicatorContent = "PullAndReleaseIndicatorContent";
|
||||
private const string PartRefreshContainer = "RefreshContainer";
|
||||
|
||||
private Border _root;
|
||||
private Border _refreshIndicatorBorder;
|
||||
private CompositeTransform _refreshIndicatorTransform;
|
||||
private ScrollViewer _scroller;
|
||||
private CompositeTransform _contentTransform;
|
||||
private CompositeTransform _headerTransform;
|
||||
private CompositeTransform _footerTransform;
|
||||
private ItemsPresenter _scrollerContent;
|
||||
private TextBlock _defaultIndicatorContent;
|
||||
private ContentPresenter _pullAndReleaseIndicatorContent;
|
||||
private ScrollBar _scrollerVerticalScrollBar;
|
||||
private double _lastOffset = 0.0;
|
||||
private double _pullDistance = 0.0;
|
||||
private DateTime _lastRefreshActivation = default(DateTime);
|
||||
private bool _refreshActivated = false;
|
||||
private bool _refreshIntentCanceled = false;
|
||||
private double _overscrollMultiplier;
|
||||
private bool _isManipulatingWithMouse;
|
||||
private double _startingVerticalOffset;
|
||||
private ControlTemplate _previousTemplateUsed;
|
||||
private RefreshContainer _refreshContainer;
|
||||
|
||||
private bool UsingRefreshContainer => IsRefreshContainerSupported && UseRefreshContainerWhenPossible;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the HamburgerMenu should use the NavigationView when possible (Fall Creators Update and above)
|
||||
/// When set to true and the device supports NavigationView, the HamburgerMenu will use a template based on NavigationView
|
||||
/// </summary>
|
||||
public bool UseRefreshContainerWhenPossible
|
||||
{
|
||||
get { return (bool)GetValue(UseRefreshContainerWhenPossibleProperty); }
|
||||
set { SetValue(UseRefreshContainerWhenPossibleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the user has requested content to be refreshed
|
||||
/// </summary>
|
||||
public event EventHandler RefreshRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the user has cancels an intent for the content to be refreshed
|
||||
/// </summary>
|
||||
public event EventHandler RefreshIntentCanceled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when listview overscroll distance is changed
|
||||
/// </summary>
|
||||
public event EventHandler<RefreshProgressEventArgs> PullProgressChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PullToRefreshListView"/> class.
|
||||
/// </summary>
|
||||
public PullToRefreshListView()
|
||||
{
|
||||
DefaultStyleKey = typeof(PullToRefreshListView);
|
||||
SizeChanged += RefreshableListView_SizeChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for SizeChanged event, handles cliping
|
||||
/// </summary>
|
||||
private void RefreshableListView_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
Clip = new RectangleGeometry()
|
||||
{
|
||||
Rect = new Rect(0, 0, e.NewSize.Width, e.NewSize.Height)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked whenever application code or internal processes (such as a rebuilding
|
||||
/// layout pass) call <see cref="OnApplyTemplate"/>. In simplest terms, this means the method
|
||||
/// is called just before a UI element displays in an application. Override this
|
||||
/// method to influence the default post-template logic of a class.
|
||||
/// </summary>
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
if (_scroller != null)
|
||||
{
|
||||
_scroller.Loaded -= Scroller_Loaded;
|
||||
_scroller.DirectManipulationCompleted -= Scroller_DirectManipulationCompleted;
|
||||
_scroller.DirectManipulationStarted -= Scroller_DirectManipulationStarted;
|
||||
}
|
||||
|
||||
if (_refreshIndicatorBorder != null)
|
||||
{
|
||||
_refreshIndicatorBorder.SizeChanged -= RefreshIndicatorBorder_SizeChanged;
|
||||
}
|
||||
|
||||
if (_root != null)
|
||||
{
|
||||
_root.ManipulationStarted -= Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted -= Scroller_ManipulationCompleted;
|
||||
}
|
||||
|
||||
_root = null;
|
||||
_refreshIndicatorBorder = null;
|
||||
_refreshIndicatorTransform = null;
|
||||
_scroller = null;
|
||||
_contentTransform = null;
|
||||
_headerTransform = null;
|
||||
_footerTransform = null;
|
||||
_scrollerContent = null;
|
||||
_defaultIndicatorContent = null;
|
||||
_pullAndReleaseIndicatorContent = null;
|
||||
_scrollerVerticalScrollBar = null;
|
||||
|
||||
if (UsingRefreshContainer)
|
||||
{
|
||||
OnApplyRefreshContainerTemplate();
|
||||
}
|
||||
|
||||
_root = GetTemplateChild(PartRoot) as Border;
|
||||
_scroller = GetTemplateChild(PartScroller) as ScrollViewer;
|
||||
_scrollerContent = GetTemplateChild(PartScrollerContent) as ItemsPresenter;
|
||||
_refreshIndicatorBorder = GetTemplateChild(PartRefreshIndicatorBorder) as Border;
|
||||
_refreshIndicatorTransform = GetTemplateChild(PartIndicatorTransform) as CompositeTransform;
|
||||
_defaultIndicatorContent = GetTemplateChild(PartDefaultIndicatorContent) as TextBlock;
|
||||
_pullAndReleaseIndicatorContent = GetTemplateChild(PullAndReleaseIndicatorContent) as ContentPresenter;
|
||||
|
||||
if (_root != null &&
|
||||
_scroller != null &&
|
||||
_scrollerContent != null &&
|
||||
_refreshIndicatorBorder != null &&
|
||||
_refreshIndicatorTransform != null &&
|
||||
(_defaultIndicatorContent != null || _pullAndReleaseIndicatorContent != null))
|
||||
{
|
||||
_scroller.Loaded += Scroller_Loaded;
|
||||
|
||||
SetupMouseMode();
|
||||
|
||||
_scroller.DirectManipulationCompleted += Scroller_DirectManipulationCompleted;
|
||||
_scroller.DirectManipulationStarted += Scroller_DirectManipulationStarted;
|
||||
|
||||
if (_defaultIndicatorContent != null)
|
||||
{
|
||||
_defaultIndicatorContent.Visibility = RefreshIndicatorContent == null ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (_pullAndReleaseIndicatorContent != null)
|
||||
{
|
||||
_pullAndReleaseIndicatorContent.Visibility = RefreshIndicatorContent == null ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
_refreshIndicatorBorder.SizeChanged += RefreshIndicatorBorder_SizeChanged;
|
||||
|
||||
_overscrollMultiplier = OverscrollLimit * 8;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
||||
private void OnApplyRefreshContainerTemplate()
|
||||
{
|
||||
if (_refreshContainer != null)
|
||||
{
|
||||
_refreshContainer.RefreshRequested -= RefreshContainer_RefreshRequested;
|
||||
}
|
||||
|
||||
_refreshContainer = GetTemplateChild(PartRefreshContainer) as RefreshContainer;
|
||||
|
||||
if (_refreshContainer != null)
|
||||
{
|
||||
_refreshContainer.RefreshRequested += RefreshContainer_RefreshRequested;
|
||||
}
|
||||
}
|
||||
|
||||
private void Scroller_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
|
||||
{
|
||||
// Other input are already managed by the scroll viewer
|
||||
if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse
|
||||
&& IsPullToRefreshWithMouseEnabled)
|
||||
{
|
||||
if (_scroller.VerticalOffset < 1)
|
||||
{
|
||||
DisplayPullToRefreshContent();
|
||||
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
||||
CompositionTarget.Rendering += CompositionTarget_Rendering;
|
||||
_isManipulatingWithMouse = true;
|
||||
}
|
||||
|
||||
_startingVerticalOffset = _scroller.VerticalOffset;
|
||||
_root.ManipulationDelta -= Scroller_ManipulationDelta;
|
||||
_root.ManipulationDelta += Scroller_ManipulationDelta;
|
||||
}
|
||||
}
|
||||
|
||||
private void Scroller_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
|
||||
{
|
||||
_root.ManipulationDelta -= Scroller_ManipulationDelta;
|
||||
|
||||
if (!IsPullToRefreshWithMouseEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OnManipulationCompleted();
|
||||
}
|
||||
|
||||
private void Scroller_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
if (!IsPullToRefreshWithMouseEnabled || _contentTransform == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Mouse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Cumulative.Translation.Y <= 0 || _scroller.VerticalOffset >= 1)
|
||||
{
|
||||
_scroller.ChangeView(_scroller.HorizontalOffset, _scroller.VerticalOffset - e.Delta.Translation.Y, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_startingVerticalOffset >= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// content is not "moved" automagically by the scrollviewer in this case
|
||||
// so we need to apply our own transformation.
|
||||
// and to do so we use a little Sin Easing.
|
||||
|
||||
// how much "drag" to go to the max translation
|
||||
var mouseMaxDragDistance = 100;
|
||||
|
||||
// make it harder to drag (life is not easy)
|
||||
double translationToUse = e.Cumulative.Translation.Y / 3;
|
||||
var deltaCumulative = Math.Min(translationToUse, mouseMaxDragDistance) / mouseMaxDragDistance;
|
||||
|
||||
// let's do some quartic ease-out
|
||||
double f = deltaCumulative - 1;
|
||||
var easing = 1 + (f * f * f * (1 - deltaCumulative));
|
||||
|
||||
var maxTranslation = 150;
|
||||
_contentTransform.TranslateY = easing * maxTranslation;
|
||||
|
||||
if (_headerTransform != null)
|
||||
{
|
||||
_headerTransform.TranslateY = _contentTransform.TranslateY;
|
||||
}
|
||||
|
||||
if (_footerTransform != null)
|
||||
{
|
||||
_footerTransform.TranslateY = _contentTransform.TranslateY;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshIndicatorBorder_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
_refreshIndicatorTransform.TranslateY = -_refreshIndicatorBorder.ActualHeight;
|
||||
}
|
||||
|
||||
private void Scroller_DirectManipulationStarted(object sender, object e)
|
||||
{
|
||||
// sometimes the value gets stuck at 0.something, so checking if less than 1
|
||||
if (_scroller.VerticalOffset < 1)
|
||||
{
|
||||
OnManipulationCompleted();
|
||||
DisplayPullToRefreshContent();
|
||||
CompositionTarget.Rendering += CompositionTarget_Rendering;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display the pull to refresh content
|
||||
/// </summary>
|
||||
private void DisplayPullToRefreshContent()
|
||||
{
|
||||
if (RefreshIndicatorContent == null)
|
||||
{
|
||||
if (_defaultIndicatorContent != null)
|
||||
{
|
||||
_defaultIndicatorContent.Text = PullToRefreshLabel;
|
||||
}
|
||||
|
||||
if (_pullAndReleaseIndicatorContent != null)
|
||||
{
|
||||
_pullAndReleaseIndicatorContent.Content = PullToRefreshContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Scroller_DirectManipulationCompleted(object sender, object e)
|
||||
{
|
||||
OnManipulationCompleted();
|
||||
_root.ManipulationMode = ManipulationModes.System;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method called at the end of manipulation to clean up everything
|
||||
/// </summary>
|
||||
private void OnManipulationCompleted()
|
||||
{
|
||||
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
||||
_refreshIndicatorTransform.TranslateY = -_refreshIndicatorBorder.ActualHeight;
|
||||
if (_contentTransform != null)
|
||||
{
|
||||
_contentTransform.TranslateY = 0;
|
||||
|
||||
if (_headerTransform != null)
|
||||
{
|
||||
_headerTransform.TranslateY = 0;
|
||||
}
|
||||
|
||||
if (_footerTransform != null)
|
||||
{
|
||||
_footerTransform.TranslateY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_refreshActivated)
|
||||
{
|
||||
RefreshRequested?.Invoke(this, EventArgs.Empty);
|
||||
if (RefreshCommand != null && RefreshCommand.CanExecute(null))
|
||||
{
|
||||
RefreshCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
else if (_refreshIntentCanceled)
|
||||
{
|
||||
RefreshIntentCanceled?.Invoke(this, EventArgs.Empty);
|
||||
if (RefreshIntentCanceledCommand != null && RefreshIntentCanceledCommand.CanExecute(null))
|
||||
{
|
||||
RefreshIntentCanceledCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
_lastOffset = 0;
|
||||
_pullDistance = 0;
|
||||
_refreshActivated = false;
|
||||
_refreshIntentCanceled = false;
|
||||
_lastRefreshActivation = default(DateTime);
|
||||
_isManipulatingWithMouse = false;
|
||||
|
||||
PullProgressChanged?.Invoke(this, new RefreshProgressEventArgs { PullProgress = 0 });
|
||||
_pullAndReleaseIndicatorContent.Content = null;
|
||||
}
|
||||
|
||||
private void CompositionTarget_Rendering(object sender, object e)
|
||||
{
|
||||
// if started navigating down, cancel the refresh
|
||||
if (_scroller.VerticalOffset > 1)
|
||||
{
|
||||
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
||||
_refreshIndicatorTransform.TranslateY = -_refreshIndicatorBorder.ActualHeight;
|
||||
if (_contentTransform != null)
|
||||
{
|
||||
_contentTransform.TranslateY = 0;
|
||||
|
||||
if (_headerTransform != null)
|
||||
{
|
||||
_headerTransform.TranslateY = 0;
|
||||
}
|
||||
|
||||
if (_footerTransform != null)
|
||||
{
|
||||
_footerTransform.TranslateY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_refreshActivated = false;
|
||||
_lastRefreshActivation = default(DateTime);
|
||||
|
||||
PullProgressChanged?.Invoke(this, new RefreshProgressEventArgs { PullProgress = 0 });
|
||||
_isManipulatingWithMouse = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_contentTransform == null)
|
||||
{
|
||||
var headerContent = VisualTreeHelper.GetChild(_scrollerContent, 0) as UIElement;
|
||||
var itemsPanel = VisualTreeHelper.GetChild(_scrollerContent, 1) as UIElement;
|
||||
var footerContent = VisualTreeHelper.GetChild(_scrollerContent, 2) as UIElement;
|
||||
|
||||
if (_headerTransform == null && VisualTreeHelper.GetChildrenCount(headerContent) > 0)
|
||||
{
|
||||
if (headerContent != null)
|
||||
{
|
||||
_headerTransform = new CompositeTransform();
|
||||
headerContent.RenderTransform = _headerTransform;
|
||||
}
|
||||
}
|
||||
|
||||
if (_footerTransform == null && VisualTreeHelper.GetChildrenCount(footerContent) > 0)
|
||||
{
|
||||
if (footerContent != null)
|
||||
{
|
||||
_footerTransform = new CompositeTransform();
|
||||
footerContent.RenderTransform = _footerTransform;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemsPanel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_contentTransform = new CompositeTransform();
|
||||
itemsPanel.RenderTransform = _contentTransform;
|
||||
}
|
||||
|
||||
Rect elementBounds = _scrollerContent.TransformToVisual(_root).TransformBounds(default(Rect));
|
||||
|
||||
// content is not "moved" automagically by the scrollviewer in this case
|
||||
// so we apply our own transformation too and need to take it in account.
|
||||
if (_isManipulatingWithMouse)
|
||||
{
|
||||
elementBounds = _contentTransform.TransformBounds(elementBounds);
|
||||
}
|
||||
|
||||
var offset = elementBounds.Y;
|
||||
var delta = offset - _lastOffset;
|
||||
_lastOffset = offset;
|
||||
|
||||
_pullDistance += delta * _overscrollMultiplier;
|
||||
|
||||
if (_isManipulatingWithMouse)
|
||||
{
|
||||
_pullDistance = 2 * offset;
|
||||
}
|
||||
|
||||
if (_pullDistance > 0)
|
||||
{
|
||||
if (!_isManipulatingWithMouse)
|
||||
{
|
||||
_contentTransform.TranslateY = _pullDistance - offset;
|
||||
|
||||
if (_headerTransform != null)
|
||||
{
|
||||
_headerTransform.TranslateY = _contentTransform.TranslateY;
|
||||
}
|
||||
|
||||
if (_footerTransform != null)
|
||||
{
|
||||
_footerTransform.TranslateY = _contentTransform.TranslateY;
|
||||
}
|
||||
}
|
||||
|
||||
if (_isManipulatingWithMouse)
|
||||
{
|
||||
_refreshIndicatorTransform.TranslateY = _pullDistance - offset
|
||||
- _refreshIndicatorBorder.ActualHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_refreshIndicatorTransform.TranslateY = _pullDistance
|
||||
- _refreshIndicatorBorder.ActualHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_isManipulatingWithMouse)
|
||||
{
|
||||
_contentTransform.TranslateY = 0;
|
||||
|
||||
if (_headerTransform != null)
|
||||
{
|
||||
_headerTransform.TranslateY = _contentTransform.TranslateY;
|
||||
}
|
||||
|
||||
if (_footerTransform != null)
|
||||
{
|
||||
_footerTransform.TranslateY = _contentTransform.TranslateY;
|
||||
}
|
||||
}
|
||||
|
||||
_refreshIndicatorTransform.TranslateY = -_refreshIndicatorBorder.ActualHeight;
|
||||
}
|
||||
|
||||
double pullProgress;
|
||||
if (_pullDistance >= PullThreshold)
|
||||
{
|
||||
_lastRefreshActivation = DateTime.Now;
|
||||
_refreshActivated = true;
|
||||
_refreshIntentCanceled = false;
|
||||
pullProgress = 1.0;
|
||||
if (RefreshIndicatorContent == null)
|
||||
{
|
||||
if (_defaultIndicatorContent != null)
|
||||
{
|
||||
_defaultIndicatorContent.Text = ReleaseToRefreshLabel;
|
||||
}
|
||||
|
||||
if (_pullAndReleaseIndicatorContent != null)
|
||||
{
|
||||
_pullAndReleaseIndicatorContent.Content = ReleaseToRefreshContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_lastRefreshActivation != DateTime.MinValue)
|
||||
{
|
||||
TimeSpan timeSinceActivated = DateTime.Now - _lastRefreshActivation;
|
||||
|
||||
// if more then a second since activation, deactivate
|
||||
if (timeSinceActivated.TotalMilliseconds > 1000)
|
||||
{
|
||||
_refreshIntentCanceled |= _refreshActivated;
|
||||
_refreshActivated = false;
|
||||
_lastRefreshActivation = default(DateTime);
|
||||
pullProgress = _pullDistance / PullThreshold;
|
||||
if (RefreshIndicatorContent == null)
|
||||
{
|
||||
if (_defaultIndicatorContent != null)
|
||||
{
|
||||
_defaultIndicatorContent.Text = PullToRefreshLabel;
|
||||
}
|
||||
|
||||
if (_pullAndReleaseIndicatorContent != null)
|
||||
{
|
||||
_pullAndReleaseIndicatorContent.Content = PullToRefreshContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pullProgress = 1.0;
|
||||
_refreshIntentCanceled |= _refreshActivated;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pullProgress = _pullDistance / PullThreshold;
|
||||
_refreshIntentCanceled |= _refreshActivated;
|
||||
}
|
||||
|
||||
PullProgressChanged?.Invoke(this, new RefreshProgressEventArgs { PullProgress = pullProgress });
|
||||
}
|
||||
|
||||
private void Scroller_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_scrollerVerticalScrollBar = _scroller.FindDescendantByName("VerticalScrollBar") as ScrollBar;
|
||||
_scrollerVerticalScrollBar.PointerEntered += ScrollerVerticalScrollBar_PointerEntered;
|
||||
_scrollerVerticalScrollBar.PointerExited += ScrollerVerticalScrollBar_PointerExited;
|
||||
}
|
||||
|
||||
private void Scroller_PointerExited(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
_root.ManipulationMode = ManipulationModes.System;
|
||||
}
|
||||
|
||||
private void Scroller_PointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (IsPullToRefreshWithMouseEnabled && e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
|
||||
{
|
||||
_root.ManipulationMode = ManipulationModes.TranslateY;
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollerVerticalScrollBar_PointerEntered(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
_root.ManipulationMode = ManipulationModes.System;
|
||||
_root.ManipulationStarted -= Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted -= Scroller_ManipulationCompleted;
|
||||
}
|
||||
|
||||
private void ScrollerVerticalScrollBar_PointerExited(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (IsPullToRefreshWithMouseEnabled)
|
||||
{
|
||||
_root.ManipulationStarted -= Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted -= Scroller_ManipulationCompleted;
|
||||
_root.ManipulationStarted += Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted += Scroller_ManipulationCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshContainer_RefreshRequested(object sender, RefreshRequestedEventArgs args)
|
||||
{
|
||||
using (var deferral = args.GetDeferral())
|
||||
{
|
||||
RefreshRequested?.Invoke(this, EventArgs.Empty);
|
||||
if (RefreshCommand != null && RefreshCommand.CanExecute(null))
|
||||
{
|
||||
RefreshCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Overscroll Limit. Value between 0 and 1 where 1 is the height of the control. Default is 0.3
|
||||
/// </summary>
|
||||
public double OverscrollLimit
|
||||
{
|
||||
get { return (double)GetValue(OverscrollLimitProperty); }
|
||||
set { SetValue(OverscrollLimitProperty, value); }
|
||||
}
|
||||
|
||||
private static void OverscrollLimitPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
double value = (double)e.NewValue;
|
||||
PullToRefreshListView view = d as PullToRefreshListView;
|
||||
|
||||
if (value >= 0 && value <= 1)
|
||||
{
|
||||
view._overscrollMultiplier = value * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IndexOutOfRangeException("OverscrollCoefficient has to be a double value between 0 and 1 inclusive.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnPullToRefreshLabelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
d.SetValue(PullToRefreshContentProperty, e.NewValue);
|
||||
}
|
||||
|
||||
private static void OnReleaseToRefreshLabelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
d.SetValue(ReleaseToRefreshLabelProperty, e.NewValue);
|
||||
}
|
||||
|
||||
private static void OnUseRefreshContainerWhenPossibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var list = d as PullToRefreshListView;
|
||||
if (list == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (list.UseRefreshContainerWhenPossible && IsRefreshContainerSupported)
|
||||
{
|
||||
ResourceDictionary dict = new ResourceDictionary();
|
||||
dict.Source = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/PullToRefreshListView/PullToRefreshListViewRefreshContainerTemplate.xaml");
|
||||
list._previousTemplateUsed = list.Template;
|
||||
list.Template = dict["PullToRefreshListViewRefreshContainerTemplate"] as ControlTemplate;
|
||||
}
|
||||
else if (!list.UseRefreshContainerWhenPossible &&
|
||||
e.OldValue is bool oldValue &&
|
||||
oldValue &&
|
||||
list._previousTemplateUsed != null)
|
||||
{
|
||||
list.Template = list._previousTemplateUsed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the PullThreshold in pixels for when Refresh should be Requested. Default is 100
|
||||
/// </summary>
|
||||
public double PullThreshold
|
||||
{
|
||||
get { return (double)GetValue(PullThresholdProperty); }
|
||||
set { SetValue(PullThresholdProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Command that will be invoked when Refresh is requested
|
||||
/// </summary>
|
||||
public ICommand RefreshCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(RefreshCommandProperty); }
|
||||
set { SetValue(RefreshCommandProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Command that will be invoked when a refresh intent is cancled
|
||||
/// </summary>
|
||||
public ICommand RefreshIntentCanceledCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(RefreshIntentCanceledCommandProperty); }
|
||||
set { SetValue(RefreshIntentCanceledCommandProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Content of the Refresh Indicator
|
||||
/// </summary>
|
||||
public object RefreshIndicatorContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return (object)GetValue(RefreshIndicatorContentProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_defaultIndicatorContent != null && _pullAndReleaseIndicatorContent != null)
|
||||
{
|
||||
_defaultIndicatorContent.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (_defaultIndicatorContent != null)
|
||||
{
|
||||
_defaultIndicatorContent.Visibility = value == null ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (_pullAndReleaseIndicatorContent != null)
|
||||
{
|
||||
_pullAndReleaseIndicatorContent.Visibility = value == null ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
SetValue(RefreshIndicatorContentProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label that will be shown when the user pulls down to refresh.
|
||||
/// Note: This label will only show up if <see cref="RefreshIndicatorContent" /> is null
|
||||
/// </summary>
|
||||
public string PullToRefreshLabel
|
||||
{
|
||||
get { return (string)GetValue(PullToRefreshLabelProperty); }
|
||||
set { SetValue(PullToRefreshLabelProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label that will be shown when the user needs to release to refresh.
|
||||
/// Note: This label will only show up if <see cref="RefreshIndicatorContent" /> is null
|
||||
/// </summary>
|
||||
public string ReleaseToRefreshLabel
|
||||
{
|
||||
get { return (string)GetValue(ReleaseToRefreshLabelProperty); }
|
||||
set { SetValue(ReleaseToRefreshLabelProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content that will be shown when the user pulls down to refresh.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This content will only show up if <see cref="RefreshIndicatorContent" /> is null
|
||||
/// </remarks>
|
||||
public object PullToRefreshContent
|
||||
{
|
||||
get { return (object)GetValue(PullToRefreshContentProperty); }
|
||||
set { SetValue(PullToRefreshContentProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content that will be shown when the user needs to release to refresh.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This content will only show up if <see cref="RefreshIndicatorContent" /> is null
|
||||
/// </remarks>
|
||||
public object ReleaseToRefreshContent
|
||||
{
|
||||
get { return (object)GetValue(ReleaseToRefreshContentProperty); }
|
||||
set { SetValue(ReleaseToRefreshContentProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether PullToRefresh is enabled with a mouse
|
||||
/// </summary>
|
||||
public bool IsPullToRefreshWithMouseEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)GetValue(IsPullToRefreshWithMouseEnabledProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(IsPullToRefreshWithMouseEnabledProperty, value);
|
||||
SetupMouseMode();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupMouseMode()
|
||||
{
|
||||
if (_root != null && _scroller != null)
|
||||
{
|
||||
if (IsPullToRefreshWithMouseEnabled)
|
||||
{
|
||||
_root.ManipulationStarted -= Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted -= Scroller_ManipulationCompleted;
|
||||
_scroller.PointerMoved -= Scroller_PointerMoved;
|
||||
_scroller.PointerExited -= Scroller_PointerExited;
|
||||
|
||||
_root.ManipulationStarted += Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted += Scroller_ManipulationCompleted;
|
||||
_scroller.PointerMoved += Scroller_PointerMoved;
|
||||
_scroller.PointerExited += Scroller_PointerExited;
|
||||
}
|
||||
else
|
||||
{
|
||||
_root.ManipulationMode = ManipulationModes.System;
|
||||
_root.ManipulationStarted -= Scroller_ManipulationStarted;
|
||||
_root.ManipulationCompleted -= Scroller_ManipulationCompleted;
|
||||
_scroller.PointerMoved -= Scroller_PointerMoved;
|
||||
_scroller.PointerExited -= Scroller_PointerExited;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/PullToRefreshListView/PullToRefreshListViewTemplate.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="local:PullToRefreshListView">
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="TabNavigation" Value="Once" />
|
||||
<Setter Property="IsSwipeEnabled" Value="True" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
|
||||
<Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled" />
|
||||
<Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="True" />
|
||||
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
|
||||
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
|
||||
<Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True" />
|
||||
<Setter Property="OverscrollLimit" Value="0.4" />
|
||||
<Setter Property="ItemContainerTransitions">
|
||||
<Setter.Value>
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition />
|
||||
<ContentThemeTransition />
|
||||
<ReorderThemeTransition />
|
||||
<EntranceThemeTransition IsStaggeringEnabled="False" />
|
||||
</TransitionCollection>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Vertical" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template" Value="{StaticResource PullToRefreshListViewTemplate}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -1,40 +0,0 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
|
||||
<ControlTemplate x:Key="PullToRefreshListViewRefreshContainerTemplate" TargetType="local:PullToRefreshListView">
|
||||
<Border x:Name="Root"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Grid>
|
||||
<RefreshContainer x:Name="RefreshContainer">
|
||||
<ScrollViewer x:Name="ScrollViewer"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
|
||||
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
|
||||
IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
|
||||
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
|
||||
IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
|
||||
TabNavigation="{TemplateBinding TabNavigation}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
|
||||
<ItemsPresenter x:Name="ItemsPresenter"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Footer="{TemplateBinding Footer}"
|
||||
FooterTemplate="{TemplateBinding FooterTemplate}"
|
||||
FooterTransitions="{TemplateBinding FooterTransitions}"
|
||||
Header="{TemplateBinding Header}"
|
||||
HeaderTemplate="{TemplateBinding HeaderTemplate}"
|
||||
HeaderTransitions="{TemplateBinding HeaderTransitions}" />
|
||||
</ScrollViewer>
|
||||
</RefreshContainer>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</ResourceDictionary>
|
|
@ -1,50 +0,0 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
|
||||
<ControlTemplate x:Key="PullToRefreshListViewTemplate" TargetType="local:PullToRefreshListView">
|
||||
<Border x:Name="Root"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Grid>
|
||||
<Border x:Name="RefreshIndicator"
|
||||
VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<ContentPresenter x:Name="PullAndReleaseIndicatorContent"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="20" />
|
||||
<ContentPresenter Content="{TemplateBinding RefreshIndicatorContent}" />
|
||||
</Grid>
|
||||
<Border.RenderTransform>
|
||||
<CompositeTransform x:Name="RefreshIndicatorTransform" />
|
||||
</Border.RenderTransform>
|
||||
</Border>
|
||||
<ScrollViewer x:Name="ScrollViewer"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
|
||||
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
|
||||
IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
|
||||
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
|
||||
IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
|
||||
TabNavigation="{TemplateBinding TabNavigation}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
|
||||
<ItemsPresenter x:Name="ItemsPresenter"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Footer="{TemplateBinding Footer}"
|
||||
FooterTemplate="{TemplateBinding FooterTemplate}"
|
||||
FooterTransitions="{TemplateBinding FooterTransitions}"
|
||||
Header="{TemplateBinding Header}"
|
||||
HeaderTemplate="{TemplateBinding HeaderTemplate}"
|
||||
HeaderTransitions="{TemplateBinding HeaderTransitions}" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</ResourceDictionary>
|
|
@ -1,19 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Event args for Refresh Progress changed event
|
||||
/// </summary>
|
||||
public class RefreshProgressEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets value from 0.0 to 1.0 where 1.0 is active
|
||||
/// </summary>
|
||||
public double PullProgress { get; set; }
|
||||
}
|
||||
}
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Windows.ApplicationModel;
|
||||
using Microsoft.Toolkit.Uwp.UI.Helpers;
|
||||
using Windows.Foundation;
|
||||
using Windows.System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Automation.Peers;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
@ -176,6 +176,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// For convenience.
|
||||
private const double Degrees2Radians = Math.PI / 180;
|
||||
|
||||
// High-contrast accessibility
|
||||
private static readonly ThemeListener ThemeListener = new ThemeListener();
|
||||
private SolidColorBrush _needleBrush;
|
||||
private Brush _trailBrush;
|
||||
private Brush _scaleBrush;
|
||||
private SolidColorBrush _scaleTickBrush;
|
||||
private SolidColorBrush _tickBrush;
|
||||
private Brush _foreground;
|
||||
|
||||
private double _normalizedMinAngle;
|
||||
private double _normalizedMaxAngle;
|
||||
|
||||
|
@ -191,7 +200,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
DefaultStyleKey = typeof(RadialGauge);
|
||||
|
||||
KeyDown += RadialGauge_KeyDown;
|
||||
Unloaded += RadialGauge_Unloaded;
|
||||
}
|
||||
|
||||
private void ThemeListener_ThemeChanged(ThemeListener sender)
|
||||
{
|
||||
OnColorsChanged();
|
||||
}
|
||||
|
||||
private void RadialGauge_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||
|
@ -217,6 +231,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
private void RadialGauge_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Unregister event handlers.
|
||||
KeyDown -= RadialGauge_KeyDown;
|
||||
ThemeListener.ThemeChanged -= ThemeListener_ThemeChanged;
|
||||
PointerReleased -= RadialGauge_PointerReleased;
|
||||
Unloaded -= RadialGauge_Unloaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value of the scale.
|
||||
/// </summary>
|
||||
|
@ -438,13 +461,32 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <value>The maximum angle, in the range from -180 to 540.</value>
|
||||
protected double NormalizedMaxAngle => _normalizedMaxAngle;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override AutomationPeer OnCreateAutomationPeer()
|
||||
{
|
||||
return new RadialGaugeAutomationPeer(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the visual state of the control when its template is changed.
|
||||
/// </summary>
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
// Remember local brushes.
|
||||
_needleBrush = ReadLocalValue(NeedleBrushProperty) as SolidColorBrush;
|
||||
_trailBrush = ReadLocalValue(TrailBrushProperty) as SolidColorBrush;
|
||||
_scaleBrush = ReadLocalValue(ScaleBrushProperty) as SolidColorBrush;
|
||||
_scaleTickBrush = ReadLocalValue(ScaleTickBrushProperty) as SolidColorBrush;
|
||||
_tickBrush = ReadLocalValue(TickBrushProperty) as SolidColorBrush;
|
||||
_foreground = ReadLocalValue(ForegroundProperty) as SolidColorBrush;
|
||||
|
||||
// Register event handlers.
|
||||
PointerReleased += RadialGauge_PointerReleased;
|
||||
OnScaleChanged(this);
|
||||
ThemeListener.ThemeChanged += ThemeListener_ThemeChanged;
|
||||
KeyDown += RadialGauge_KeyDown;
|
||||
|
||||
// Apply color scheme.
|
||||
OnColorsChanged();
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
@ -650,6 +692,48 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
OnValueChanged(radialGauge);
|
||||
}
|
||||
|
||||
private void OnColorsChanged()
|
||||
{
|
||||
if (ThemeListener.IsHighContrast)
|
||||
{
|
||||
// Apply High Contrast Theme.
|
||||
ClearBrush(_needleBrush, NeedleBrushProperty);
|
||||
ClearBrush(_trailBrush, TrailBrushProperty);
|
||||
ClearBrush(_scaleBrush, ScaleBrushProperty);
|
||||
ClearBrush(_scaleBrush, ScaleTickBrushProperty);
|
||||
ClearBrush(_tickBrush, TickBrushProperty);
|
||||
ClearBrush(_foreground, ForegroundProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply User Defined or Default Theme.
|
||||
RestoreBrush(_needleBrush, NeedleBrushProperty);
|
||||
RestoreBrush(_trailBrush, TrailBrushProperty);
|
||||
RestoreBrush(_scaleBrush, ScaleBrushProperty);
|
||||
RestoreBrush(_scaleBrush, ScaleTickBrushProperty);
|
||||
RestoreBrush(_tickBrush, TickBrushProperty);
|
||||
RestoreBrush(_foreground, ForegroundProperty);
|
||||
}
|
||||
|
||||
OnScaleChanged(this);
|
||||
}
|
||||
|
||||
private void ClearBrush(Brush brush, DependencyProperty prop)
|
||||
{
|
||||
if (brush != null)
|
||||
{
|
||||
ClearValue(prop);
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreBrush(Brush source, DependencyProperty prop)
|
||||
{
|
||||
if (source != null)
|
||||
{
|
||||
SetValue(prop, source);
|
||||
}
|
||||
}
|
||||
|
||||
private void RadialGauge_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
SetGaugeValueFromPoint(e.Position);
|
||||
|
|
|
@ -2,14 +2,85 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
<ResourceDictionary x:Key="Default">
|
||||
<SolidColorBrush x:Key="RadialGaugeNeedleBrush"
|
||||
Color="{ThemeResource SystemChromeHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTrailBrush"
|
||||
Color="{ThemeResource SystemChromeHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleBrush"
|
||||
Color="{ThemeResource SystemBaseMediumLowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleTickBrush"
|
||||
Color="{ThemeResource SystemBaseMediumLowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTickBrush"
|
||||
Color="{ThemeResource SystemBaseHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeForeground"
|
||||
Color="{ThemeResource SystemBaseHighColor}" />
|
||||
</ResourceDictionary>
|
||||
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="RadialGaugeNeedleBrush"
|
||||
Color="{ThemeResource SystemChromeHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTrailBrush"
|
||||
Color="{ThemeResource SystemChromeHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleBrush"
|
||||
Color="{ThemeResource SystemBaseMediumLowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleTickBrush"
|
||||
Color="{ThemeResource SystemBaseMediumLowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTickBrush"
|
||||
Color="{ThemeResource SystemBaseHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeForeground"
|
||||
Color="{ThemeResource SystemBaseHighColor}" />
|
||||
</ResourceDictionary>
|
||||
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SolidColorBrush x:Key="RadialGaugeNeedleBrush"
|
||||
Color="{ThemeResource SystemChromeHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTrailBrush"
|
||||
Color="{ThemeResource SystemChromeHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleBrush"
|
||||
Color="{ThemeResource SystemBaseMediumLowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleTickBrush"
|
||||
Color="{ThemeResource SystemBaseMediumLowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTickBrush"
|
||||
Color="{ThemeResource SystemBaseHighColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeForeground"
|
||||
Color="{ThemeResource SystemBaseHighColor}" />
|
||||
</ResourceDictionary>
|
||||
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<SolidColorBrush x:Key="RadialGaugeNeedleBrush"
|
||||
Color="{ThemeResource SystemColorHotlightColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTrailBrush"
|
||||
Color="{ThemeResource SystemColorHotlightColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleBrush"
|
||||
Color="{ThemeResource SystemColorWindowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeScaleTickBrush"
|
||||
Color="{ThemeResource SystemColorWindowColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeTickBrush"
|
||||
Color="{ThemeResource SystemColorWindowTextColor}" />
|
||||
<SolidColorBrush x:Key="RadialGaugeForeground"
|
||||
Color="{ThemeResource SystemColorWindowTextColor}" />
|
||||
</ResourceDictionary>
|
||||
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
<Style TargetType="local:RadialGauge">
|
||||
<Setter Property="NeedleBrush" Value="{ThemeResource SystemControlBackgroundAccentBrush}" />
|
||||
<Setter Property="TrailBrush" Value="{ThemeResource SystemControlBackgroundAccentBrush}" />
|
||||
<Setter Property="ScaleBrush" Value="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}" />
|
||||
<Setter Property="ScaleTickBrush" Value="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}" />
|
||||
<Setter Property="TickBrush" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
|
||||
<Setter Property="UseSystemFocusVisuals" Value="True" />
|
||||
<Setter Property="NeedleBrush"
|
||||
Value="{ThemeResource RadialGaugeNeedleBrush}" />
|
||||
<Setter Property="TrailBrush"
|
||||
Value="{ThemeResource RadialGaugeTrailBrush}" />
|
||||
<Setter Property="ScaleBrush"
|
||||
Value="{ThemeResource RadialGaugeScaleBrush}" />
|
||||
<Setter Property="ScaleTickBrush"
|
||||
Value="{ThemeResource RadialGaugeScaleTickBrush}" />
|
||||
<Setter Property="TickBrush"
|
||||
Value="{ThemeResource RadialGaugeTickBrush}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{ThemeResource RadialGaugeForeground}" />
|
||||
<Setter Property="UseSystemFocusVisuals"
|
||||
Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="local:RadialGauge">
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI.Xaml.Automation.Peers;
|
||||
using Windows.UI.Xaml.Automation.Provider;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Exposes <see cref="RadialGauge"/> to Microsoft UI Automation.
|
||||
/// </summary>
|
||||
public class RadialGaugeAutomationPeer :
|
||||
FrameworkElementAutomationPeer,
|
||||
IRangeValueProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RadialGaugeAutomationPeer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner element to create for.</param>
|
||||
public RadialGaugeAutomationPeer(RadialGauge owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool IsReadOnly => !((RadialGauge)Owner).IsInteractive;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double LargeChange => ((RadialGauge)Owner).StepSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double Maximum => ((RadialGauge)Owner).Maximum;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double Minimum => ((RadialGauge)Owner).Minimum;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double SmallChange => ((RadialGauge)Owner).StepSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double Value => ((RadialGauge)Owner).Value;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetValue(double value)
|
||||
{
|
||||
((RadialGauge)Owner).Value = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override IList<AutomationPeer> GetChildrenCore()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetNameCore()
|
||||
{
|
||||
var gauge = (RadialGauge)Owner;
|
||||
return "radial gauge. " + (string.IsNullOrWhiteSpace(gauge.Unit) ? "no unit specified. " : "unit " + gauge.Unit + ". ");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override object GetPatternCore(PatternInterface patternInterface)
|
||||
{
|
||||
if (patternInterface == PatternInterface.RangeValue)
|
||||
{
|
||||
// Expose RangeValue properties.
|
||||
return this;
|
||||
}
|
||||
|
||||
return base.GetPatternCore(patternInterface);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override AutomationControlType GetAutomationControlTypeCore()
|
||||
{
|
||||
return AutomationControlType.Custom;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplatePart(Name = OutlineArcPartName, Type = typeof(ArcSegment))]
|
||||
[TemplatePart(Name = BarFigurePartName, Type = typeof(PathFigure))]
|
||||
[TemplatePart(Name = BarArcPartName, Type = typeof(ArcSegment))]
|
||||
public sealed class RadialProgressBar : ProgressBar
|
||||
public class RadialProgressBar : ProgressBar
|
||||
{
|
||||
private const string OutlineFigurePartName = "OutlineFigurePart";
|
||||
private const string OutlineArcPartName = "OutlineArcPart";
|
||||
|
|
|
@ -1,953 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Toolkit.Uwp.UI.Animations;
|
||||
using Windows.Devices.Input;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Metadata;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// ContentControl providing functionality for sliding left or right to expose functions
|
||||
/// </summary>
|
||||
[TemplatePart(Name = PartContentGrid, Type = typeof(Grid))]
|
||||
[TemplatePart(Name = PartCommandContainer, Type = typeof(Grid))]
|
||||
[TemplatePart(Name = PartLeftCommandPanel, Type = typeof(StackPanel))]
|
||||
[TemplatePart(Name = PartRightCommandPanel, Type = typeof(StackPanel))]
|
||||
[Obsolete("The SlidableListItem will be removed in a future major release. Please use the SwipeControl available in the Fall Creators Update")]
|
||||
public class SlidableListItem : ContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ExtraSwipeThreshold"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ExtraSwipeThresholdProperty =
|
||||
DependencyProperty.Register(nameof(ExtraSwipeThreshold), typeof(int), typeof(SlidableListItem), new PropertyMetadata(default(int)));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="IsOffsetLimited"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsOffsetLimitedProperty =
|
||||
DependencyProperty.Register(nameof(IsOffsetLimited), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="IsRightCommandEnabled"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsRightCommandEnabledProperty =
|
||||
DependencyProperty.Register(nameof(IsRightCommandEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="IsLeftCommandEnabled"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsLeftCommandEnabledProperty =
|
||||
DependencyProperty.Register(nameof(IsLeftCommandEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ActivationWidth"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ActivationWidthProperty =
|
||||
DependencyProperty.Register(nameof(ActivationWidth), typeof(double), typeof(SlidableListItem), new PropertyMetadata(80));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LeftIcon"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LeftIconProperty =
|
||||
DependencyProperty.Register(nameof(LeftIcon), typeof(Symbol), typeof(SlidableListItem), new PropertyMetadata(Symbol.Favorite, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RightIcon"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RightIconProperty =
|
||||
DependencyProperty.Register(nameof(RightIcon), typeof(Symbol), typeof(SlidableListItem), new PropertyMetadata(Symbol.Delete, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LeftLabel"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LeftLabelProperty =
|
||||
DependencyProperty.Register(nameof(LeftLabel), typeof(string), typeof(SlidableListItem), new PropertyMetadata(string.Empty, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RightLabel"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RightLabelProperty =
|
||||
DependencyProperty.Register(nameof(RightLabel), typeof(string), typeof(SlidableListItem), new PropertyMetadata(string.Empty, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LeftForeground"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LeftForegroundProperty =
|
||||
DependencyProperty.Register(nameof(LeftForeground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.White), OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RightForeground"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RightForegroundProperty =
|
||||
DependencyProperty.Register(nameof(RightForeground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.White), OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LeftBackground"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LeftBackgroundProperty =
|
||||
DependencyProperty.Register(nameof(LeftBackground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.LightGray), OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RightBackground"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RightBackgroundProperty =
|
||||
DependencyProperty.Register(nameof(RightBackground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.DarkGray), OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="MouseSlidingEnabled"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MouseSlidingEnabledProperty =
|
||||
DependencyProperty.Register(nameof(MouseSlidingEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(false));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LeftCommand"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LeftCommandProperty =
|
||||
DependencyProperty.Register(nameof(LeftCommand), typeof(ICommand), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RightCommand"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RightCommandProperty =
|
||||
DependencyProperty.Register(nameof(RightCommand), typeof(ICommand), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LeftCommandParameter"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LeftCommandParameterProperty =
|
||||
DependencyProperty.Register(nameof(LeftCommandParameter), typeof(object), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="RightCommandParameter"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RightCommandParameterProperty =
|
||||
DependencyProperty.Register(nameof(RightCommandParameter), typeof(object), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="SwipeStatus"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SwipeStatusProperty =
|
||||
DependencyProperty.Register(nameof(SwipeStatus), typeof(object), typeof(SlidableListItem), new PropertyMetadata(SwipeStatus.Idle));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="IsPointerReleasedOnSwipingHandled"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsPointerReleasedOnSwipingHandledProperty =
|
||||
DependencyProperty.Register("IsPointerReleasedOnSwipingHandled", typeof(bool), typeof(SlidableListItem), new PropertyMetadata(false));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="UseSwipeControlWhenPossible"/> dependency property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty UseSwipeControlWhenPossibleProperty =
|
||||
DependencyProperty.Register("UseSwipeControlWhenPossible", typeof(bool), typeof(SlidableListItem), new PropertyMetadata(false, OnUseSwipeControlWhenPossibleChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when SwipeStatus has changed
|
||||
/// </summary>
|
||||
public event TypedEventHandler<SlidableListItem, SwipeStatusChangedEventArgs> SwipeStatusChanged;
|
||||
|
||||
private const string PartContentGrid = "ContentGrid";
|
||||
private const string PartCommandContainer = "CommandContainer";
|
||||
private const string PartLeftCommandPanel = "LeftCommandPanel";
|
||||
private const string PartRightCommandPanel = "RightCommandPanel";
|
||||
private const int FinishAnimationDuration = 150;
|
||||
private const int SnappedCommandMargin = 20;
|
||||
private const int AnimationSetDuration = 200;
|
||||
|
||||
private Grid _contentGrid;
|
||||
private CompositeTransform _transform;
|
||||
private Grid _commandContainer;
|
||||
private CompositeTransform _commandContainerTransform;
|
||||
private DoubleAnimation _commandContainerClipTranslateAnimation;
|
||||
private StackPanel _leftCommandPanel;
|
||||
private CompositeTransform _leftCommandTransform;
|
||||
private StackPanel _rightCommandPanel;
|
||||
private CompositeTransform _rightCommandTransform;
|
||||
private DoubleAnimation _contentAnimation;
|
||||
private Storyboard _contentStoryboard;
|
||||
private AnimationSet _leftCommandAnimationSet;
|
||||
private AnimationSet _rightCommandAnimationSet;
|
||||
|
||||
private ControlTemplate _previousTemplateUsed;
|
||||
private object _swipeControl;
|
||||
private object _leftSwipeItems;
|
||||
private object _leftSwipeItem;
|
||||
private object _rightSwipeItems;
|
||||
private object _rightSwipeItem;
|
||||
|
||||
private bool UsingSwipeControl => UseSwipeControlWhenPossible && IsSwipeControlSupported;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether <see cref="SwipeControl"/> is supported
|
||||
/// </summary>
|
||||
public static bool IsSwipeControlSupported { get; } = ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.SwipeControl");
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SlidableListItem"/> class.
|
||||
/// Creates a new instance of <see cref="SlidableListItem"/>
|
||||
/// </summary>
|
||||
public SlidableListItem()
|
||||
{
|
||||
DefaultStyleKey = typeof(SlidableListItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the user swipes to the left to activate the right action
|
||||
/// </summary>
|
||||
public event EventHandler RightCommandRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the user swipes to the right to activate the left action
|
||||
/// </summary>
|
||||
public event EventHandler LeftCommandRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked whenever application code or internal processes (such as a rebuilding
|
||||
/// layout pass) call <see cref="OnApplyTemplate"/>. In simplest terms, this means the method
|
||||
/// is called just before a UI element displays in an application. Override this
|
||||
/// method to influence the default post-template logic of a class.
|
||||
/// </summary>
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
if (_contentGrid != null)
|
||||
{
|
||||
_contentGrid.PointerReleased -= ContentGrid_PointerReleased;
|
||||
_contentGrid.ManipulationStarted -= ContentGrid_ManipulationStarted;
|
||||
_contentGrid.ManipulationDelta -= ContentGrid_ManipulationDelta;
|
||||
_contentGrid.ManipulationCompleted -= ContentGrid_ManipulationCompleted;
|
||||
}
|
||||
|
||||
_contentGrid = GetTemplateChild(PartContentGrid) as Grid;
|
||||
|
||||
if (_contentGrid != null)
|
||||
{
|
||||
_contentGrid.PointerReleased += ContentGrid_PointerReleased;
|
||||
|
||||
_transform = _contentGrid.RenderTransform as CompositeTransform;
|
||||
_contentGrid.ManipulationStarted += ContentGrid_ManipulationStarted;
|
||||
_contentGrid.ManipulationDelta += ContentGrid_ManipulationDelta;
|
||||
_contentGrid.ManipulationCompleted += ContentGrid_ManipulationCompleted;
|
||||
}
|
||||
|
||||
if (UsingSwipeControl)
|
||||
{
|
||||
OnApplyTemplateSwipeControl();
|
||||
}
|
||||
|
||||
Loaded += SlidableListItem_Loaded;
|
||||
Unloaded += SlidableListItem_Unloaded;
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
||||
private static void OnUseSwipeControlWhenPossibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var slider = d as SlidableListItem;
|
||||
if (slider == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (slider.UseSwipeControlWhenPossible && SlidableListItem.IsSwipeControlSupported)
|
||||
{
|
||||
ResourceDictionary dict = new ResourceDictionary();
|
||||
dict.Source = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem/SlidableListItemSwipeControlTemplate.xaml");
|
||||
slider._previousTemplateUsed = slider.Template;
|
||||
slider.Template = dict["SlidableListItemSwipeControlStyle"] as ControlTemplate;
|
||||
}
|
||||
else if (!slider.UseSwipeControlWhenPossible &&
|
||||
e.OldValue is bool oldValue &&
|
||||
oldValue)
|
||||
{
|
||||
if (slider._previousTemplateUsed != null)
|
||||
{
|
||||
slider.Template = slider._previousTemplateUsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceDictionary dict = new ResourceDictionary();
|
||||
dict.Source = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem/SlidableListItem.xaml");
|
||||
slider.Template = dict["SlidableListItemDefaultTemplate"] as ControlTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSwipeControlValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is SlidableListItem control && control.UsingSwipeControl)
|
||||
{
|
||||
control.UpdateSwipeControlItems();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnApplyTemplateSwipeControl()
|
||||
{
|
||||
if (GetTemplateChild("SwipeControl") is SwipeControl swipeControl)
|
||||
{
|
||||
_swipeControl = swipeControl;
|
||||
UpdateSwipeControlItems();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSwipeControlItems()
|
||||
{
|
||||
var swipeControl = _swipeControl as SwipeControl;
|
||||
if (swipeControl == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsLeftCommandEnabled)
|
||||
{
|
||||
var leftItem = _leftSwipeItem as SwipeItem;
|
||||
var leftItems = _leftSwipeItems as SwipeItems;
|
||||
|
||||
if (leftItem == null)
|
||||
{
|
||||
leftItem = new SwipeItem();
|
||||
leftItem.IconSource = new SymbolIconSource();
|
||||
leftItem.Invoked += LeftControl_Invoked;
|
||||
|
||||
leftItems = new SwipeItems()
|
||||
{
|
||||
leftItem
|
||||
};
|
||||
leftItems.Mode = SwipeMode.Execute;
|
||||
|
||||
_leftSwipeItems = leftItems;
|
||||
_leftSwipeItem = leftItem;
|
||||
}
|
||||
|
||||
leftItem.BehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
|
||||
leftItem.Background = LeftBackground;
|
||||
leftItem.Text = LeftLabel;
|
||||
leftItem.Foreground = LeftForeground;
|
||||
leftItem.Command = LeftCommand;
|
||||
leftItem.CommandParameter = LeftCommandParameter;
|
||||
leftItem.IconSource.Foreground = LeftForeground;
|
||||
((SymbolIconSource)leftItem.IconSource).Symbol = LeftIcon;
|
||||
|
||||
swipeControl.LeftItems = leftItems;
|
||||
}
|
||||
else
|
||||
{
|
||||
swipeControl.LeftItems = null;
|
||||
}
|
||||
|
||||
if (IsRightCommandEnabled)
|
||||
{
|
||||
var rightItem = _rightSwipeItem as SwipeItem;
|
||||
var rightItems = _rightSwipeItems as SwipeItems;
|
||||
|
||||
if (rightItem == null)
|
||||
{
|
||||
rightItem = new SwipeItem();
|
||||
rightItem.IconSource = new SymbolIconSource();
|
||||
rightItem.Invoked += RightControl_Invoked;
|
||||
|
||||
rightItems = new SwipeItems()
|
||||
{
|
||||
rightItem
|
||||
};
|
||||
rightItems.Mode = SwipeMode.Execute;
|
||||
|
||||
_rightSwipeItems = rightItems;
|
||||
_rightSwipeItem = rightItem;
|
||||
}
|
||||
|
||||
rightItem.BehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
|
||||
rightItem.Background = RightBackground;
|
||||
rightItem.Text = RightLabel;
|
||||
rightItem.Foreground = RightForeground;
|
||||
rightItem.Command = RightCommand;
|
||||
rightItem.CommandParameter = RightCommandParameter;
|
||||
rightItem.IconSource.Foreground = RightForeground;
|
||||
((SymbolIconSource)rightItem.IconSource).Symbol = RightIcon;
|
||||
|
||||
swipeControl.RightItems = rightItems;
|
||||
}
|
||||
else
|
||||
{
|
||||
swipeControl.RightItems = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LeftControl_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
|
||||
{
|
||||
LeftCommandRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void RightControl_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
|
||||
{
|
||||
RightCommandRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void SlidableListItem_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_contentStoryboard != null)
|
||||
{
|
||||
_contentStoryboard.Completed += ContentStoryboard_Completed;
|
||||
}
|
||||
}
|
||||
|
||||
private void SlidableListItem_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_contentStoryboard != null)
|
||||
{
|
||||
_contentStoryboard.Completed -= ContentStoryboard_Completed;
|
||||
}
|
||||
}
|
||||
|
||||
private void ContentGrid_PointerReleased(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (SwipeStatus != SwipeStatus.Idle && IsPointerReleasedOnSwipingHandled)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ContentGrid_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
|
||||
{
|
||||
if ((!MouseSlidingEnabled && e.PointerDeviceType == PointerDeviceType.Mouse) || (!IsLeftCommandEnabled && !IsRightCommandEnabled))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_contentStoryboard == null)
|
||||
{
|
||||
_contentAnimation = new DoubleAnimation();
|
||||
Storyboard.SetTarget(_contentAnimation, _transform);
|
||||
Storyboard.SetTargetProperty(_contentAnimation, "TranslateX");
|
||||
_contentAnimation.To = 0;
|
||||
_contentAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(FinishAnimationDuration));
|
||||
|
||||
_contentStoryboard = new Storyboard();
|
||||
_contentStoryboard.Children.Add(_contentAnimation);
|
||||
|
||||
_contentStoryboard.Completed += ContentStoryboard_Completed;
|
||||
}
|
||||
|
||||
if (_commandContainer == null)
|
||||
{
|
||||
_commandContainer = GetTemplateChild(PartCommandContainer) as Grid;
|
||||
if (_commandContainer != null)
|
||||
{
|
||||
_commandContainer.Background = LeftBackground as Brush;
|
||||
_commandContainer.Clip = new RectangleGeometry();
|
||||
_commandContainerTransform = new CompositeTransform();
|
||||
_commandContainer.Clip.Transform = _commandContainerTransform;
|
||||
|
||||
_commandContainerClipTranslateAnimation = new DoubleAnimation();
|
||||
Storyboard.SetTarget(_commandContainerClipTranslateAnimation, _commandContainerTransform);
|
||||
Storyboard.SetTargetProperty(_commandContainerClipTranslateAnimation, "TranslateX");
|
||||
_commandContainerClipTranslateAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(FinishAnimationDuration));
|
||||
_contentStoryboard.Children.Add(_commandContainerClipTranslateAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
if (_leftCommandPanel == null)
|
||||
{
|
||||
_leftCommandPanel = GetTemplateChild(PartLeftCommandPanel) as StackPanel;
|
||||
if (_leftCommandPanel != null)
|
||||
{
|
||||
_leftCommandTransform = _leftCommandPanel.RenderTransform as CompositeTransform;
|
||||
}
|
||||
}
|
||||
|
||||
if (_rightCommandPanel == null)
|
||||
{
|
||||
_rightCommandPanel = GetTemplateChild(PartRightCommandPanel) as StackPanel;
|
||||
if (_rightCommandPanel != null)
|
||||
{
|
||||
_rightCommandTransform = _rightCommandPanel.RenderTransform as CompositeTransform;
|
||||
}
|
||||
}
|
||||
|
||||
_contentStoryboard.Stop();
|
||||
_commandContainer.Opacity = 0;
|
||||
_commandContainerTransform.TranslateX = 0;
|
||||
_transform.TranslateX = 0;
|
||||
SwipeStatus = SwipeStatus.Starting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for when slide manipulation is complete
|
||||
/// </summary>
|
||||
private void ContentGrid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
|
||||
{
|
||||
if (SwipeStatus == SwipeStatus.Idle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var x = _transform.TranslateX;
|
||||
_contentAnimation.From = x;
|
||||
_commandContainerClipTranslateAnimation.From = 0;
|
||||
_commandContainerClipTranslateAnimation.To = -x;
|
||||
_contentStoryboard.Begin();
|
||||
|
||||
if (SwipeStatus == SwipeStatus.SwipingPassedLeftThreshold)
|
||||
{
|
||||
RightCommandRequested?.Invoke(this, EventArgs.Empty);
|
||||
RightCommand?.Execute(RightCommandParameter);
|
||||
}
|
||||
else if (SwipeStatus == SwipeStatus.SwipingPassedRightThreshold)
|
||||
{
|
||||
LeftCommandRequested?.Invoke(this, EventArgs.Empty);
|
||||
LeftCommand?.Execute(LeftCommandParameter);
|
||||
}
|
||||
|
||||
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SwipeStatus = SwipeStatus.Idle; }).AsTask();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for when slide manipulation is underway
|
||||
/// </summary>
|
||||
private void ContentGrid_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
if (SwipeStatus == SwipeStatus.Idle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newTranslationX = _transform.TranslateX + e.Delta.Translation.X;
|
||||
bool swipingInDisabledArea = false;
|
||||
SwipeStatus newSwipeStatus = SwipeStatus.Idle;
|
||||
|
||||
if (newTranslationX > 0)
|
||||
{
|
||||
// Swiping from left to right
|
||||
if (!IsLeftCommandEnabled)
|
||||
{
|
||||
// If swipe is not enabled, only allow swipe a very short distance
|
||||
if (newTranslationX > 0)
|
||||
{
|
||||
swipingInDisabledArea = true;
|
||||
newSwipeStatus = SwipeStatus.DisabledSwipingToRight;
|
||||
}
|
||||
|
||||
if (newTranslationX > 16)
|
||||
{
|
||||
newTranslationX = 16;
|
||||
}
|
||||
}
|
||||
else if (IsOffsetLimited)
|
||||
{
|
||||
// If offset is limited, there will be a limit how much swipe is possible.
|
||||
// This will be the value of the command panel plus some threshold.
|
||||
// This value can't be less than the ActivationWidth.
|
||||
var swipeThreshold = _leftCommandPanel.ActualWidth + ExtraSwipeThreshold;
|
||||
if (swipeThreshold < ActivationWidth)
|
||||
{
|
||||
swipeThreshold = ActivationWidth;
|
||||
}
|
||||
|
||||
if (Math.Abs(newTranslationX) > swipeThreshold)
|
||||
{
|
||||
newTranslationX = swipeThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow swiping more than almost the whole content grid width
|
||||
// (doing this will cause the control to change size).
|
||||
if (newTranslationX > (_contentGrid.ActualWidth - 4))
|
||||
{
|
||||
newTranslationX = _contentGrid.ActualWidth - 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Swiping from right to left
|
||||
if (!IsRightCommandEnabled)
|
||||
{
|
||||
// If swipe is not enabled, only allow swipe a very short distance
|
||||
if (newTranslationX < 0)
|
||||
{
|
||||
swipingInDisabledArea = true;
|
||||
newSwipeStatus = SwipeStatus.DisabledSwipingToLeft;
|
||||
}
|
||||
|
||||
if (newTranslationX < -16)
|
||||
{
|
||||
newTranslationX = -16;
|
||||
}
|
||||
}
|
||||
else if (IsOffsetLimited)
|
||||
{
|
||||
// If offset is limited, there will be a limit how much swipe is possible.
|
||||
// This will be the value of the command panel plus some threshold.
|
||||
// This value can't be less than the ActivationWidth.
|
||||
var swipeThreshold = _rightCommandPanel.ActualWidth + ExtraSwipeThreshold;
|
||||
if (swipeThreshold < ActivationWidth)
|
||||
{
|
||||
swipeThreshold = ActivationWidth;
|
||||
}
|
||||
|
||||
if (Math.Abs(newTranslationX) > swipeThreshold)
|
||||
{
|
||||
newTranslationX = -swipeThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow swiping more than almost the whole content grid width
|
||||
// (doing this will cause the control to change size).
|
||||
if (newTranslationX < -(_contentGrid.ActualWidth - 4))
|
||||
{
|
||||
newTranslationX = -(_contentGrid.ActualWidth - 4);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasPassedThreshold = !swipingInDisabledArea && Math.Abs(newTranslationX) >= ActivationWidth;
|
||||
|
||||
if (swipingInDisabledArea)
|
||||
{
|
||||
// Don't show any command if swiping in disabled area.
|
||||
_commandContainer.Opacity = 0;
|
||||
_leftCommandPanel.Opacity = 0;
|
||||
_rightCommandPanel.Opacity = 0;
|
||||
}
|
||||
else if (newTranslationX > 0)
|
||||
{
|
||||
// If swiping from left to right, show left command panel.
|
||||
_rightCommandPanel.Opacity = 0;
|
||||
|
||||
_commandContainer.Background = LeftBackground as Brush;
|
||||
_commandContainer.Opacity = 1;
|
||||
_leftCommandPanel.Opacity = 1;
|
||||
|
||||
_commandContainer.Clip.Rect = new Rect(0, 0, Math.Max(newTranslationX - 1, 0), _commandContainer.ActualHeight);
|
||||
|
||||
if (newTranslationX < ActivationWidth)
|
||||
{
|
||||
_leftCommandAnimationSet?.Stop();
|
||||
_leftCommandPanel.RenderTransform = _leftCommandTransform;
|
||||
_leftCommandTransform.TranslateX = newTranslationX / 2;
|
||||
|
||||
newSwipeStatus = SwipeStatus.SwipingToRightThreshold;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SwipeStatus == SwipeStatus.SwipingToRightThreshold)
|
||||
{
|
||||
// The control was just put below the threshold.
|
||||
// Run an animation to put the text and icon
|
||||
// in the correct position.
|
||||
_leftCommandAnimationSet = _leftCommandPanel.Offset((float)(SnappedCommandMargin - _leftCommandTransform.TranslateX), duration: AnimationSetDuration);
|
||||
_leftCommandAnimationSet.Start();
|
||||
}
|
||||
else if (SwipeStatus != SwipeStatus.SwipingPassedRightThreshold)
|
||||
{
|
||||
// This will cover extreme cases when previous state wasn't
|
||||
// below threshold.
|
||||
_leftCommandAnimationSet?.Stop();
|
||||
_leftCommandPanel.RenderTransform = _leftCommandTransform;
|
||||
_leftCommandTransform.TranslateX = SnappedCommandMargin;
|
||||
}
|
||||
|
||||
newSwipeStatus = SwipeStatus.SwipingPassedRightThreshold;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If swiping from right to left, show right command panel.
|
||||
_leftCommandPanel.Opacity = 0;
|
||||
|
||||
_commandContainer.Background = RightBackground as Brush;
|
||||
_commandContainer.Opacity = 1;
|
||||
_rightCommandPanel.Opacity = 1;
|
||||
|
||||
_commandContainer.Clip.Rect = new Rect(_commandContainer.ActualWidth + newTranslationX + 1, 0, Math.Max(-newTranslationX - 1, 0), _commandContainer.ActualHeight);
|
||||
|
||||
if (-newTranslationX < ActivationWidth)
|
||||
{
|
||||
_rightCommandAnimationSet?.Stop();
|
||||
_rightCommandPanel.RenderTransform = _rightCommandTransform;
|
||||
_rightCommandTransform.TranslateX = newTranslationX / 2;
|
||||
|
||||
newSwipeStatus = SwipeStatus.SwipingToLeftThreshold;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SwipeStatus == SwipeStatus.SwipingToLeftThreshold)
|
||||
{
|
||||
// The control was just put below the threshold.
|
||||
// Run an animation to put the text and icon
|
||||
// in the correct position.
|
||||
_rightCommandAnimationSet = _rightCommandPanel.Offset((float)(-SnappedCommandMargin - _rightCommandTransform.TranslateX), duration: AnimationSetDuration);
|
||||
_rightCommandAnimationSet.Start();
|
||||
}
|
||||
else if (SwipeStatus != SwipeStatus.SwipingPassedLeftThreshold)
|
||||
{
|
||||
// This will cover extreme cases when previous state wasn't
|
||||
// below threshold.
|
||||
_rightCommandAnimationSet?.Stop();
|
||||
_rightCommandPanel.RenderTransform = _rightCommandTransform;
|
||||
_rightCommandTransform.TranslateX = -SnappedCommandMargin;
|
||||
}
|
||||
|
||||
newSwipeStatus = SwipeStatus.SwipingPassedLeftThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
_transform.TranslateX = newTranslationX;
|
||||
SwipeStatus = newSwipeStatus;
|
||||
}
|
||||
|
||||
private void ContentStoryboard_Completed(object sender, object e)
|
||||
{
|
||||
_commandContainer.Opacity = 0.0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of extra pixels for swipe threshold when <see cref="IsOffsetLimited"/> is enabled.
|
||||
/// </summary>
|
||||
public int ExtraSwipeThreshold
|
||||
{
|
||||
get { return (int)GetValue(ExtraSwipeThresholdProperty); }
|
||||
set { SetValue(ExtraSwipeThresholdProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether maximum swipe offset is limited or not.
|
||||
/// </summary>
|
||||
public bool IsOffsetLimited
|
||||
{
|
||||
get { return (bool)GetValue(IsOffsetLimitedProperty); }
|
||||
set { SetValue(IsOffsetLimitedProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether right command is enabled or not.
|
||||
/// </summary>
|
||||
public bool IsRightCommandEnabled
|
||||
{
|
||||
get { return (bool)GetValue(IsRightCommandEnabledProperty); }
|
||||
set { SetValue(IsRightCommandEnabledProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether left command is enabled or not.
|
||||
/// </summary>
|
||||
public bool IsLeftCommandEnabled
|
||||
{
|
||||
get { return (bool)GetValue(IsLeftCommandEnabledProperty); }
|
||||
set { SetValue(IsLeftCommandEnabledProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of pixels the content needs to be swiped for an
|
||||
/// action to be requested
|
||||
/// </summary>
|
||||
public double ActivationWidth
|
||||
{
|
||||
get { return (double)GetValue(ActivationWidthProperty); }
|
||||
set { SetValue(ActivationWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left icon symbol
|
||||
/// </summary>
|
||||
public Symbol LeftIcon
|
||||
{
|
||||
get { return (Symbol)GetValue(LeftIconProperty); }
|
||||
set { SetValue(LeftIconProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the right icon symbol
|
||||
/// </summary>
|
||||
public Symbol RightIcon
|
||||
{
|
||||
get { return (Symbol)GetValue(RightIconProperty); }
|
||||
set { SetValue(RightIconProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left label
|
||||
/// </summary>
|
||||
public string LeftLabel
|
||||
{
|
||||
get { return (string)GetValue(LeftLabelProperty); }
|
||||
set { SetValue(LeftLabelProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the right label
|
||||
/// </summary>
|
||||
public string RightLabel
|
||||
{
|
||||
get { return (string)GetValue(RightLabelProperty); }
|
||||
set { SetValue(RightLabelProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left foreground color
|
||||
/// </summary>
|
||||
public Brush LeftForeground
|
||||
{
|
||||
get { return (Brush)GetValue(LeftForegroundProperty); }
|
||||
set { SetValue(LeftForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the right foreground color
|
||||
/// </summary>
|
||||
public Brush RightForeground
|
||||
{
|
||||
get { return (Brush)GetValue(RightForegroundProperty); }
|
||||
set { SetValue(RightForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left background color
|
||||
/// </summary>
|
||||
public Brush LeftBackground
|
||||
{
|
||||
get { return (Brush)GetValue(LeftBackgroundProperty); }
|
||||
set { SetValue(LeftBackgroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the right background color
|
||||
/// </summary>
|
||||
public Brush RightBackground
|
||||
{
|
||||
get { return (Brush)GetValue(RightBackgroundProperty); }
|
||||
set { SetValue(RightBackgroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether it has the ability to slide the control with the mouse. False by default
|
||||
/// </summary>
|
||||
public bool MouseSlidingEnabled
|
||||
{
|
||||
get { return (bool)GetValue(MouseSlidingEnabledProperty); }
|
||||
set { SetValue(MouseSlidingEnabledProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ICommand for left command request
|
||||
/// </summary>
|
||||
public ICommand LeftCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ICommand)GetValue(LeftCommandProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(LeftCommandProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ICommand for right command request
|
||||
/// </summary>
|
||||
public ICommand RightCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ICommand)GetValue(RightCommandProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(RightCommandProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CommandParameter for left command request
|
||||
/// </summary>
|
||||
public object LeftCommandParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetValue(LeftCommandParameterProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(LeftCommandParameterProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CommandParameter for right command request
|
||||
/// </summary>
|
||||
public object RightCommandParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetValue(RightCommandParameterProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(RightCommandParameterProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SwipeStatus for current swipe status
|
||||
/// </summary>
|
||||
public SwipeStatus SwipeStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (SwipeStatus)GetValue(SwipeStatusProperty);
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
var oldValue = SwipeStatus;
|
||||
|
||||
if (value != oldValue)
|
||||
{
|
||||
SetValue(SwipeStatusProperty, value);
|
||||
|
||||
var eventArguments = new SwipeStatusChangedEventArgs()
|
||||
{
|
||||
OldValue = oldValue,
|
||||
NewValue = value
|
||||
};
|
||||
|
||||
SwipeStatusChanged?.Invoke(this, eventArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the PointerReleased event is handled when swiping.
|
||||
/// Set this to <value>true</value> to prevent ItemClicked or selection to occur when swiping in a <see cref="ListView"/>
|
||||
/// </summary>
|
||||
public bool IsPointerReleasedOnSwipingHandled
|
||||
{
|
||||
get { return (bool)GetValue(IsPointerReleasedOnSwipingHandledProperty); }
|
||||
set { SetValue(IsPointerReleasedOnSwipingHandledProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the SlidableListItem should use the SwipeControl when possible (Fall Creators Update and above)
|
||||
/// When set to true and the device supports SwipeControl, the SlidableListItem will use a template based on SwipeControl
|
||||
/// </summary>
|
||||
public bool UseSwipeControlWhenPossible
|
||||
{
|
||||
get { return (bool)GetValue(UseSwipeControlWhenPossibleProperty); }
|
||||
set { SetValue(UseSwipeControlWhenPossibleProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
|
||||
<ControlTemplate TargetType="controls:SlidableListItem" x:Key="SlidableListItemDefaultTemplate">
|
||||
<Grid>
|
||||
<Grid x:Name="CommandContainer"
|
||||
Margin="1"
|
||||
x:DeferLoadStrategy="Lazy">
|
||||
<StackPanel x:Name="LeftCommandPanel"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<SymbolIcon Foreground="{TemplateBinding LeftForeground}"
|
||||
Symbol="{TemplateBinding LeftIcon}" />
|
||||
<TextBlock Margin="10,0,0,0"
|
||||
FontSize="15"
|
||||
Foreground="{TemplateBinding LeftForeground}"
|
||||
Text="{TemplateBinding LeftLabel}" />
|
||||
<StackPanel.RenderTransform>
|
||||
<CompositeTransform />
|
||||
</StackPanel.RenderTransform>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="RightCommandPanel"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Margin="0,0,10,0"
|
||||
FontSize="15"
|
||||
Foreground="{TemplateBinding RightForeground}"
|
||||
Text="{TemplateBinding RightLabel}" />
|
||||
<SymbolIcon Foreground="{TemplateBinding RightForeground}"
|
||||
Symbol="{TemplateBinding RightIcon}" />
|
||||
<StackPanel.RenderTransform>
|
||||
<CompositeTransform />
|
||||
</StackPanel.RenderTransform>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid x:Name="ContentGrid"
|
||||
Background="{TemplateBinding Background}"
|
||||
ManipulationMode="TranslateX,System">
|
||||
<ContentPresenter />
|
||||
<Grid.RenderTransform>
|
||||
<CompositeTransform x:Name="ContentTransform" />
|
||||
</Grid.RenderTransform>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style TargetType="controls:SlidableListItem">
|
||||
<Setter Property="LeftForeground" Value="White" />
|
||||
<Setter Property="RightForeground" Value="White" />
|
||||
<Setter Property="LeftBackground" Value="LightGray" />
|
||||
<Setter Property="RightBackground" Value="DarkGray" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="ActivationWidth" Value="80" />
|
||||
<Setter Property="IsOffsetLimited" Value="True" />
|
||||
<Setter Property="ExtraSwipeThreshold" Value="40" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Template" Value="{StaticResource SlidableListItemDefaultTemplate}"></Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -1,15 +0,0 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:Windows10FallCreatorsUpdate="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 5)">
|
||||
|
||||
<ControlTemplate x:Key="SlidableListItemSwipeControlStyle" TargetType="local:SlidableListItem">
|
||||
<Windows10FallCreatorsUpdate:SwipeControl x:Name="SwipeControl">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<ContentPresenter />
|
||||
</Grid>
|
||||
</Windows10FallCreatorsUpdate:SwipeControl>
|
||||
</ControlTemplate>
|
||||
|
||||
</ResourceDictionary>
|
|
@ -1,55 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Types of swipe status.
|
||||
/// </summary>
|
||||
[Obsolete("The SwipeStatus will be removed alongside SlidableListItem in a future major release. Please use the SwipeControl available in the Fall Creators Update")]
|
||||
public enum SwipeStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Swiping is not occurring.
|
||||
/// </summary>
|
||||
Idle,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping is going to start.
|
||||
/// </summary>
|
||||
Starting,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping to the left, but the command is disabled.
|
||||
/// </summary>
|
||||
DisabledSwipingToLeft,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping to the left below the threshold.
|
||||
/// </summary>
|
||||
SwipingToLeftThreshold,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping to the left above the threshold.
|
||||
/// </summary>
|
||||
SwipingPassedLeftThreshold,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping to the right, but the command is disabled.
|
||||
/// </summary>
|
||||
DisabledSwipingToRight,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping to the right below the threshold.
|
||||
/// </summary>
|
||||
SwipingToRightThreshold,
|
||||
|
||||
/// <summary>
|
||||
/// Swiping to the right above the threshold.
|
||||
/// </summary>
|
||||
SwipingPassedRightThreshold
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Event args for a SwipeStatus changing event
|
||||
/// </summary>
|
||||
[Obsolete("The SwipeStatusChangedEventArgs will be removed alongside SlidableListItem in a future major release. Please use the SwipeControl available in the Fall Creators Update")]
|
||||
public class SwipeStatusChangedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the old value.
|
||||
/// </summary>
|
||||
public SwipeStatus OldValue { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new value.
|
||||
/// </summary>
|
||||
public SwipeStatus NewValue { get; internal set; }
|
||||
}
|
||||
}
|
|
@ -4,12 +4,10 @@
|
|||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/HeaderedContentControl/HeaderedContentControl.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/HeaderedItemsControl/HeaderedItemsControl.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem/SlidableListItem.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/ImageEx/ImageEx.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/RadialProgressBar/RadialProgressBar.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/PullToRefreshListView/PullToRefreshListView.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/RotatorTile/RotatorTile.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/BladeView/BladeView.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter/GridSplitter.xaml" />
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// A ContentControl that show an image repeated many times.
|
||||
/// The control can be synchronized with a Scrollviewer and animated easily.
|
||||
/// </summary>
|
||||
public sealed class TileControl : ContentControl
|
||||
public class TileControl : ContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ScrollViewerContainer"/> property.
|
||||
|
|
|
@ -27,13 +27,11 @@
|
|||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.OrbitView" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.OrbitViewItem" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.OrbitViewPanel" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.PullToRefreshListView" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.RadialGauge" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.RadialProgressBar" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.RangeSelector" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.RotatorTile" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.ScrollHeader" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.SlidableListItem" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.StaggeredPanel" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.TextToolbar" />
|
||||
<Item Type="Microsoft.Toolkit.Uwp.UI.Controls.TileControl" />
|
||||
|
|
|
@ -31,16 +31,13 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
|
||||
private readonly bool _liveShapingEnabled;
|
||||
|
||||
private readonly HashSet<string> _observedFilterProperties = new HashSet<string>();
|
||||
|
||||
private IList _source;
|
||||
|
||||
private Predicate<object> _filter;
|
||||
|
||||
private int _index;
|
||||
|
||||
private int _deferCounter;
|
||||
|
||||
private HashSet<string> _observedFilterProperties = new HashSet<string>();
|
||||
|
||||
private WeakEventListener<AdvancedCollectionView, object, NotifyCollectionChangedEventArgs> _sourceWeakEventListener;
|
||||
|
||||
/// <summary>
|
||||
|
@ -94,8 +91,7 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
|
||||
_sourceWeakEventListener?.Detach();
|
||||
|
||||
var sourceNcc = _source as INotifyCollectionChanged;
|
||||
if (sourceNcc != null)
|
||||
if (_source is INotifyCollectionChanged sourceNcc)
|
||||
{
|
||||
_sourceWeakEventListener =
|
||||
new WeakEventListener<AdvancedCollectionView, object, NotifyCollectionChangedEventArgs>(this)
|
||||
|
@ -254,13 +250,13 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
/// Move current item to next item
|
||||
/// </summary>
|
||||
/// <returns>success of operation</returns>
|
||||
public bool MoveCurrentToNext() => MoveCurrentToIndex(_index + 1);
|
||||
public bool MoveCurrentToNext() => MoveCurrentToIndex(CurrentPosition + 1);
|
||||
|
||||
/// <summary>
|
||||
/// Move current item to previous item
|
||||
/// </summary>
|
||||
/// <returns>success of operation</returns>
|
||||
public bool MoveCurrentToPrevious() => MoveCurrentToIndex(_index - 1);
|
||||
public bool MoveCurrentToPrevious() => MoveCurrentToIndex(CurrentPosition - 1);
|
||||
|
||||
/// <summary>
|
||||
/// Load more items from the source
|
||||
|
@ -284,14 +280,14 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
/// </summary>
|
||||
public object CurrentItem
|
||||
{
|
||||
get { return _index > -1 && _index < _view.Count ? _view[_index] : null; }
|
||||
get { return CurrentPosition > -1 && CurrentPosition < _view.Count ? _view[CurrentPosition] : null; }
|
||||
set { MoveCurrentTo(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position of current item
|
||||
/// </summary>
|
||||
public int CurrentPosition => _index;
|
||||
public int CurrentPosition { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the source has more items
|
||||
|
@ -301,12 +297,12 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
/// <summary>
|
||||
/// Gets a value indicating whether the current item is after the last visible item
|
||||
/// </summary>
|
||||
public bool IsCurrentAfterLast => _index >= _view.Count;
|
||||
public bool IsCurrentAfterLast => CurrentPosition >= _view.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current item is before the first visible item
|
||||
/// </summary>
|
||||
public bool IsCurrentBeforeFirst => _index < 0;
|
||||
public bool IsCurrentBeforeFirst => CurrentPosition < 0;
|
||||
|
||||
/// <summary>
|
||||
/// Current item changed event handler
|
||||
|
@ -324,7 +320,7 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
public bool CanFilter => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the predicate used to filter the visisble items
|
||||
/// Gets or sets the predicate used to filter the visible items
|
||||
/// </summary>
|
||||
public Predicate<object> Filter
|
||||
{
|
||||
|
@ -472,18 +468,33 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
if ((filterResult ?? true) && SortDescriptions.Any(sd => sd.PropertyName == e.PropertyName))
|
||||
{
|
||||
var oldIndex = _view.IndexOf(item);
|
||||
_view.RemoveAt(oldIndex);
|
||||
OnVectorChanged(new VectorChangedEventArgs(CollectionChange.ItemRemoved, oldIndex, item));
|
||||
|
||||
// Check if item is in view:
|
||||
if (oldIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_view.RemoveAt(oldIndex);
|
||||
var targetIndex = _view.BinarySearch(item, this);
|
||||
if (targetIndex < 0)
|
||||
{
|
||||
targetIndex = ~targetIndex;
|
||||
}
|
||||
|
||||
_view.Insert(targetIndex, item);
|
||||
// Only trigger expensive UI updates if the index really changed:
|
||||
if (targetIndex != oldIndex)
|
||||
{
|
||||
OnVectorChanged(new VectorChangedEventArgs(CollectionChange.ItemRemoved, oldIndex, item));
|
||||
|
||||
OnVectorChanged(new VectorChangedEventArgs(CollectionChange.ItemInserted, targetIndex, item));
|
||||
_view.Insert(targetIndex, item);
|
||||
|
||||
OnVectorChanged(new VectorChangedEventArgs(CollectionChange.ItemInserted, targetIndex, item));
|
||||
}
|
||||
else
|
||||
{
|
||||
_view.Insert(targetIndex, item);
|
||||
}
|
||||
}
|
||||
else if (string.IsNullOrEmpty(e.PropertyName))
|
||||
{
|
||||
|
@ -697,9 +708,9 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
}
|
||||
|
||||
_view.Insert(newViewIndex, newItem);
|
||||
if (newViewIndex <= _index)
|
||||
if (newViewIndex <= CurrentPosition)
|
||||
{
|
||||
_index++;
|
||||
CurrentPosition++;
|
||||
}
|
||||
|
||||
var e = new VectorChangedEventArgs(CollectionChange.ItemInserted, newViewIndex, newItem);
|
||||
|
@ -730,9 +741,9 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
private void RemoveFromView(int itemIndex, object item)
|
||||
{
|
||||
_view.RemoveAt(itemIndex);
|
||||
if (itemIndex <= _index)
|
||||
if (itemIndex <= CurrentPosition)
|
||||
{
|
||||
_index--;
|
||||
CurrentPosition--;
|
||||
}
|
||||
|
||||
var e = new VectorChangedEventArgs(CollectionChange.ItemRemoved, itemIndex, item);
|
||||
|
@ -756,7 +767,7 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
return false;
|
||||
}
|
||||
|
||||
if (i == _index)
|
||||
if (i == CurrentPosition)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -768,7 +779,7 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
return false;
|
||||
}
|
||||
|
||||
_index = i;
|
||||
CurrentPosition = i;
|
||||
OnCurrentChanged(null);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Extensions">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI/Extensions/NavigationView/Styles/VSCodeActivityBarStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
|
@ -1,285 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Set of extensions for the <see cref="NavigationView"/> control.
|
||||
/// </summary>
|
||||
[Bindable]
|
||||
[Obsolete("The Navigation View extension will be removed in a future major release.")]
|
||||
public static class NavigationViewExtensions
|
||||
{
|
||||
// Name of Content area in NavigationView Template.
|
||||
private const string CONTENT_GRID = "ContentGrid";
|
||||
|
||||
// Name of the 'Unselected' item we use to track null selection to workaround NavigationView behavior change in 17134.
|
||||
private const string UNSELECTED_ITEM_NAME = "UWPT_NVE_UNSELECTED";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the selected <see cref="NavigationViewItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.NavigationView"/>.</param>
|
||||
/// <returns>The selected index.</returns>
|
||||
public static int GetSelectedIndex(NavigationView obj)
|
||||
{
|
||||
return (int)obj.GetValue(SelectedIndexProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the index of the selected <see cref="NavigationViewItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.NavigationView"/>.</param>
|
||||
/// <param name="value">The index to select.</param>
|
||||
public static void SetSelectedIndex(NavigationView obj, int value)
|
||||
{
|
||||
obj.SetValue(SelectedIndexProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attached <see cref="DependencyProperty"/> for binding the selected index of a <see cref="NavigationView"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.RegisterAttached("SelectedIndex", typeof(int), typeof(NavigationViewExtensions), new PropertyMetadata(-1, OnSelectedIndexChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value representing if the settings page is selected for the <see cref="NavigationViewItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.NavigationView"/>.</param>
|
||||
/// <returns>True if the settings page is selected.</returns>
|
||||
public static bool GetIsSettingsSelected(NavigationView obj)
|
||||
{
|
||||
return (bool)obj.GetValue(IsSettingsSelectedProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a value representing if the settings page is selected for the <see cref="NavigationViewItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.NavigationView"/>.</param>
|
||||
/// <param name="value">Set to True to select the settings page.</param>
|
||||
public static void SetIsSettingsSelected(NavigationView obj, bool value)
|
||||
{
|
||||
obj.SetValue(IsSettingsSelectedProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attached <see cref="DependencyProperty"/> for selecting the Settings Page of a <see cref="NavigationView"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsSettingsSelectedProperty =
|
||||
DependencyProperty.RegisterAttached("IsSettingsSelected", typeof(bool), typeof(NavigationViewExtensions), new PropertyMetadata(false, OnIsSettingsSelectedChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the behavior to collapse the content when clicking the already selected <see cref="NavigationViewItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.NavigationView"/>.</param>
|
||||
/// <returns>True if the feature is on.</returns>
|
||||
public static bool GetCollapseOnClick(NavigationView obj)
|
||||
{
|
||||
return (bool)obj.GetValue(CollapseOnClickProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the behavior to collapse the content when clicking the already selected <see cref="NavigationViewItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.NavigationView"/>.</param>
|
||||
/// <param name="value">True to turn on this feature.</param>
|
||||
public static void SetCollapseOnClick(NavigationView obj, bool value)
|
||||
{
|
||||
obj.SetValue(CollapseOnClickProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attached <see cref="DependencyProperty"/> for enabling the behavior to collapse the <see cref="NavigationView"/> content when the same selected item is invoked again (click or tap).
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CollapseOnClickProperty =
|
||||
DependencyProperty.RegisterAttached("CollapseOnClick", typeof(bool), typeof(NavigationViewExtensions), new PropertyMetadata(false, OnCollapseOnClickChanged));
|
||||
|
||||
// Private helper to mark a hidden object for 'unselected' state to work around not being able to set SelectedItem to null in 17134.
|
||||
private static NavigationViewItem GetSelectionPlaceholder(NavigationView obj)
|
||||
{
|
||||
return (NavigationViewItem)obj.GetValue(SelectionPlaceholderProperty);
|
||||
}
|
||||
|
||||
private static void SetSelectionPlaceholder(NavigationView obj, NavigationViewItem value)
|
||||
{
|
||||
obj.SetValue(SelectionPlaceholderProperty, value);
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for SelectionPlaceholder. This enables animation, styling, binding, etc...
|
||||
private static readonly DependencyProperty SelectionPlaceholderProperty =
|
||||
DependencyProperty.RegisterAttached("SelectionPlaceholder", typeof(NavigationViewItem), typeof(NavigationViewItem), new PropertyMetadata(null));
|
||||
|
||||
private static void OnCollapseOnClickChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
// This should always be a NavigationView.
|
||||
var navview = (NavigationView)d;
|
||||
|
||||
navview.ItemInvoked -= Navview_ItemInvoked;
|
||||
|
||||
if ((bool?)e.NewValue == true)
|
||||
{
|
||||
// Listen for clicks on navigation items
|
||||
navview.ItemInvoked += Navview_ItemInvoked;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure we're visible if we toggle this off.
|
||||
var content = navview.FindDescendantByName(CONTENT_GRID);
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
content.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Navview_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
|
||||
{
|
||||
// We're doing this here instead of on property initialization
|
||||
// so that we add our 'dummy' item at the end of the list
|
||||
// and don't disrupt the order of the list.
|
||||
InjectSelectionPlaceholder(sender);
|
||||
|
||||
var content = sender.FindDescendantByName(CONTENT_GRID);
|
||||
|
||||
var unselected = GetSelectionPlaceholder(sender);
|
||||
if (content != null)
|
||||
{
|
||||
// If we click the item we already have selected, we want to collapse our content
|
||||
/* Bug with NavView fires twice for Settings, so we can't use this logic until fixed...
|
||||
* (GetIsSettingsSelected(sender) ?
|
||||
args.InvokedItem == sender.SelectedItem :
|
||||
args.InvokedItem.Equals(((NavigationViewItem)sender.SelectedItem).Content))
|
||||
*/
|
||||
if (sender.SelectedItem != null && sender.SelectedItem != unselected &&
|
||||
args.InvokedItem.Equals(((NavigationViewItem)sender.SelectedItem).Content))
|
||||
{
|
||||
// We need to dispatch this so the underlying selection event from our invoke processes.
|
||||
// Otherwise, we just end up back where we started. We don't care about waiting for this to finish.
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
sender.Dispatcher.RunIdleAsync((e) =>
|
||||
{
|
||||
sender.SelectedItem = unselected;
|
||||
});
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
|
||||
content.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
content.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we've injected our workaround or not yet for 17134 (prevents setting SelectedItem back to null).
|
||||
private static void InjectSelectionPlaceholder(NavigationView sender)
|
||||
{
|
||||
if (sender != null && GetSelectionPlaceholder(sender) == null)
|
||||
{
|
||||
var temp = new NavigationViewItem()
|
||||
{
|
||||
Content = UNSELECTED_ITEM_NAME,
|
||||
Visibility = Visibility.Collapsed
|
||||
};
|
||||
|
||||
sender.MenuItems.Add(temp);
|
||||
SetSelectionPlaceholder(sender, temp);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var navview = (NavigationView)d;
|
||||
|
||||
// If we're trying to unselect something, inject then.
|
||||
// Otherwise we'll mess up starting order of items and indices.
|
||||
if (e.NewValue as int? == -1)
|
||||
{
|
||||
InjectSelectionPlaceholder(navview);
|
||||
}
|
||||
|
||||
navview.Loaded -= Navview_Loaded;
|
||||
Navview_Loaded(d, null); // For changes
|
||||
navview.Loaded += Navview_Loaded;
|
||||
|
||||
navview.SelectionChanged -= Obj_SelectionChanged;
|
||||
navview.SelectionChanged += Obj_SelectionChanged;
|
||||
}
|
||||
|
||||
private static void OnIsSettingsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var navview = (NavigationView)d;
|
||||
|
||||
if (e.NewValue.Equals(true))
|
||||
{
|
||||
navview.SelectedItem = navview.SettingsItem;
|
||||
}
|
||||
else if (navview.SelectedItem == navview.SettingsItem)
|
||||
{
|
||||
navview.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Navview_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var navview = (NavigationView)sender;
|
||||
|
||||
int value = GetSelectedIndex(navview);
|
||||
|
||||
if (value >= 0 && value < navview.MenuItems.Count)
|
||||
{
|
||||
// Skip over our hidden item, if needed.
|
||||
if (navview.MenuItems[value] == GetSelectionPlaceholder(navview))
|
||||
{
|
||||
value++;
|
||||
if (value >= navview.MenuItems.Count)
|
||||
{
|
||||
navview.SelectedItem = GetSelectionPlaceholder(navview);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Only update if we need to.
|
||||
if (navview.SelectedItem == null || !navview.SelectedItem.Equals(navview.MenuItems[value] as NavigationViewItem))
|
||||
{
|
||||
navview.SelectedItem = navview.MenuItems[value];
|
||||
}
|
||||
}
|
||||
else if (GetIsSettingsSelected(navview))
|
||||
{
|
||||
navview.SelectedItem = navview.SettingsItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
navview.SelectedItem = GetSelectionPlaceholder(navview);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Obj_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||
{
|
||||
// Store state of settings selected.
|
||||
SetIsSettingsSelected(sender, args.IsSettingsSelected);
|
||||
|
||||
if (!args.IsSettingsSelected && args.SelectedItem != null &&
|
||||
args.SelectedItem != GetSelectionPlaceholder(sender))
|
||||
{
|
||||
var index = sender.MenuItems.IndexOf(args.SelectedItem);
|
||||
if (index != GetSelectedIndex(sender))
|
||||
{
|
||||
SetSelectedIndex(sender, index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSelectedIndex(sender, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Extensions"
|
||||
xmlns:Windows10FallCreatorsUpdate="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 5)">
|
||||
|
||||
<Windows10FallCreatorsUpdate:ControlTemplate x:Key="VSCodeActivityBarTemplate"
|
||||
TargetType="NavigationView">
|
||||
<Grid x:Name="RootGrid">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="HeaderGroup">
|
||||
<VisualState x:Name="HeaderVisible"/>
|
||||
<VisualState x:Name="HeaderCollapsed">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="HeaderContent.Visibility" Value="Collapsed"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="SettingsGroup">
|
||||
<VisualState x:Name="SettingsVisible"/>
|
||||
<VisualState x:Name="SettingsCollapsed">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="SettingsNavPaneItem.Visibility" Value="Collapsed"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="AutoSuggestGroup">
|
||||
<VisualState x:Name="AutoSuggestBoxVisible"/>
|
||||
<VisualState x:Name="AutoSuggestBoxCollapsed">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="AutoSuggestArea.Visibility" Value="Collapsed"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="PaneStateGroup">
|
||||
<VisualState x:Name="NotClosedCompact"/>
|
||||
<VisualState x:Name="ClosedCompact">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="PaneAutoSuggestBoxPresenter.Visibility" Value="Collapsed"/>
|
||||
<Setter Target="PaneAutoSuggestButton.Visibility" Value="Visible"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<SplitView x:Name="RootSplitView"
|
||||
Background="{TemplateBinding Background}"
|
||||
DisplayMode="Inline"
|
||||
IsTabStop="False"
|
||||
IsPaneOpen="False"
|
||||
OpenPaneLength="48"
|
||||
PaneBackground="{ThemeResource NavigationViewDefaultPaneBackground}">
|
||||
<SplitView.Pane>
|
||||
<Grid x:Name="PaneContentGrid" Margin="0,-48,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition x:Name="PaneContentGridToggleButtonRow" Height="56"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="8"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="ContentPaneTopPadding"/>
|
||||
<Grid x:Name="AutoSuggestArea" Height="40" Grid.Row="2" VerticalAlignment="Center">
|
||||
<ContentControl x:Name="PaneAutoSuggestBoxPresenter" Content="{TemplateBinding AutoSuggestBox}" HorizontalContentAlignment="Stretch" IsTabStop="False" Margin="12,0,12,0" VerticalContentAlignment="Center"/>
|
||||
<Button x:Name="PaneAutoSuggestButton" Content="" MinHeight="40" Style="{TemplateBinding PaneToggleButtonStyle}" Visibility="Collapsed" Width="{TemplateBinding CompactPaneLength}"/>
|
||||
</Grid>
|
||||
<Windows10FallCreatorsUpdate:NavigationViewList x:Name="MenuItemsHost" ItemContainerStyleSelector="{TemplateBinding MenuItemContainerStyleSelector}" ItemContainerStyle="{TemplateBinding MenuItemContainerStyle}" ItemTemplate="{TemplateBinding MenuItemTemplate}" IsItemClickEnabled="True" ItemsSource="{TemplateBinding MenuItemsSource}" ItemTemplateSelector="{TemplateBinding MenuItemTemplateSelector}" Margin="0,0,0,20" Grid.Row="3" SelectionMode="Single" SelectedItem="{TemplateBinding SelectedItem}"/>
|
||||
<Border x:Name="FooterContentBorder" Child="{TemplateBinding PaneFooter}" Grid.Row="4"/>
|
||||
<Windows10FallCreatorsUpdate:NavigationViewItem x:Name="SettingsNavPaneItem" Grid.Row="5" Icon="Setting" Style="{TemplateBinding MenuItemContainerStyle}"/>
|
||||
</Grid>
|
||||
</SplitView.Pane>
|
||||
<Grid x:Name="ContentGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl x:Name="HeaderContent" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" HorizontalContentAlignment="Stretch" IsTabStop="False" MinHeight="48" VerticalContentAlignment="Stretch"/>
|
||||
<ContentPresenter Content="{TemplateBinding Content}" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</SplitView>
|
||||
</Grid>
|
||||
</Windows10FallCreatorsUpdate:ControlTemplate>
|
||||
|
||||
<Windows10FallCreatorsUpdate:Style x:Key="VSCodeActivityBarStyle" TargetType="NavigationView">
|
||||
<Setter Property="PaneToggleButtonStyle" Value="{StaticResource PaneToggleButtonStyle}"/>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid Margin="12,5,0,11" VerticalAlignment="Stretch">
|
||||
<TextBlock x:Name="Header" Style="{StaticResource TitleTextBlockStyle}" Text="{Binding}" TextWrapping="NoWrap" VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="CompactModeThresholdWidth" Value="0"/>
|
||||
<Setter Property="ExpandedModeThresholdWidth" Value="0"/>
|
||||
<Setter Property="AlwaysShowHeader" Value="False"/>
|
||||
<Setter Property="Template" Value="{StaticResource VSCodeActivityBarTemplate}"/>
|
||||
</Windows10FallCreatorsUpdate:Style>
|
||||
|
||||
<Windows10FallCreatorsUpdate:ControlTemplate x:Key="LargeIconNavigationViewItemTemplate"
|
||||
TargetType="NavigationViewItem">
|
||||
<Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}" Height="48" Control.IsTemplateFocusTarget="True">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="PointerStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="PointerOver"/>
|
||||
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundPointerOver}"/>
|
||||
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushPointerOver}"/>
|
||||
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundPointerOver}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="Pressed"/>
|
||||
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundPressed}"/>
|
||||
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushPressed}"/>
|
||||
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundPressed}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Selected">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundSelected}"/>
|
||||
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushSelected}"/>
|
||||
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundSelected}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="PointerOverSelected">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="PointerOver"/>
|
||||
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundSelectedPointerOver}"/>
|
||||
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushSelectedPointerOver}"/>
|
||||
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundSelectedPointerOver}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="PressedSelected">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="Pressed"/>
|
||||
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundSelectedPressed}"/>
|
||||
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushSelectedPressed}"/>
|
||||
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundSelectedPressed}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="DisabledStates">
|
||||
<VisualState x:Name="Enabled"/>
|
||||
<VisualState x:Name="Disabled">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LayoutRoot.Opacity" Value="{ThemeResource ListViewItemDisabledThemeOpacity}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="PaneStates">
|
||||
<VisualState x:Name="NotClosedCompact"/>
|
||||
<VisualState x:Name="ClosedCompact">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RevealBorder.HorizontalAlignment" Value="Left"/>
|
||||
<Setter Target="RevealBorder.Width" Value="{Binding CompactPaneLength, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="IconStates">
|
||||
<VisualState x:Name="IconVisible"/>
|
||||
<VisualState x:Name="IconCollapsed">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="IconBox.Visibility" Value="Collapsed"/>
|
||||
<Setter Target="IconColumn.Width" Value="16"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<Rectangle x:Name="SelectionIndicator" Fill="{ThemeResource NavigationViewSelectionIndicatorForeground}" Height="24" Opacity="0.0" Width="6"/>
|
||||
</Grid>
|
||||
<Border x:Name="RevealBorder" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"/>
|
||||
<Grid HorizontalAlignment="Left" Height="40">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="IconColumn" Width="48"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Viewbox x:Name="IconBox" Child="{TemplateBinding Icon}" Margin="10,8" ToolTipService.ToolTip="{TemplateBinding Content}"/>
|
||||
<ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Windows10FallCreatorsUpdate:ControlTemplate>
|
||||
|
||||
<Windows10FallCreatorsUpdate:Style x:Key="LargeIconNavigationViewItemStyle" TargetType="NavigationViewItem">
|
||||
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}"/>
|
||||
<Setter Property="Background" Value="{ThemeResource NavigationViewItemBackground}"/>
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="{StaticResource NavigationViewItemBorderThickness}"/>
|
||||
<Setter Property="UseSystemFocusVisuals" Value="True"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Template" Value="{StaticResource LargeIconNavigationViewItemTemplate}"/>
|
||||
</Windows10FallCreatorsUpdate:Style>
|
||||
</ResourceDictionary>
|
|
@ -210,5 +210,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Extensions
|
|||
|
||||
return parent.FindAscendant(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find all visual ascendants for the element.
|
||||
/// </summary>
|
||||
/// <param name="element">Child element.</param>
|
||||
/// <returns>A collection of parent elements or null if none found.</returns>
|
||||
public static IEnumerable<DependencyObject> FindAscendants(this DependencyObject element)
|
||||
{
|
||||
var parent = VisualTreeHelper.GetParent(element);
|
||||
|
||||
while (parent != null)
|
||||
{
|
||||
yield return parent;
|
||||
parent = VisualTreeHelper.GetParent(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,5 +86,22 @@ namespace Microsoft.Toolkit.Wpf.UI.XamlHost
|
|||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
protected override System.IntPtr WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
|
||||
{
|
||||
const int WM_GETOBJECT = 0x003D;
|
||||
switch (msg)
|
||||
{
|
||||
// We don't want HwndHost to handle the WM_GETOBJECT.
|
||||
// Instead we want to let the HwndIslandSite's WndProc get it
|
||||
// So return handled = false and don't let the base class do
|
||||
// anything on that message.
|
||||
case WM_GETOBJECT:
|
||||
handled = false;
|
||||
return System.IntPtr.Zero;
|
||||
}
|
||||
|
||||
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Services.Bing;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace UnitTests.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class Test_BingService
|
||||
{
|
||||
private const string Query = @"Windows 10";
|
||||
|
||||
[TestCategory("Services")]
|
||||
[TestMethod]
|
||||
public async Task Test_BingServiceSearch_Request()
|
||||
{
|
||||
BingSearchConfig config = new BingSearchConfig();
|
||||
config.Country = BingCountry.UnitedStates;
|
||||
config.QueryType = BingQueryType.Search;
|
||||
config.Query = Query;
|
||||
|
||||
var results = await BingService.Instance.RequestAsync(config, 50);
|
||||
|
||||
Assert.AreEqual(results.Count, 50);
|
||||
}
|
||||
|
||||
[TestCategory("Services")]
|
||||
[TestMethod]
|
||||
public async Task Test_BingServiceNews_Request()
|
||||
{
|
||||
BingSearchConfig config = new BingSearchConfig();
|
||||
config.Country = BingCountry.UnitedStates;
|
||||
config.QueryType = BingQueryType.News;
|
||||
config.Query = Query;
|
||||
|
||||
var results = await BingService.Instance.RequestAsync(config, 50);
|
||||
|
||||
Assert.IsTrue(results.Count > 5);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -164,7 +164,6 @@
|
|||
<Compile Include="Markdown\TestBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\Test_WeakEventListener.cs" />
|
||||
<Compile Include="Services\Test_BingService.cs" />
|
||||
<Compile Include="UI\Controls\Test_UniformGrid_AutoLayout.cs" />
|
||||
<Compile Include="UI\Controls\Test_UniformGrid_RowColDefinitions.cs" />
|
||||
<Compile Include="UI\Controls\Test_UniformGrid_FreeSpots.cs" />
|
||||
|
@ -215,10 +214,6 @@
|
|||
<Project>{b1e850ff-dde6-44d5-a830-34250e97a687}</Project>
|
||||
<Name>Microsoft.Toolkit.Uwp.Connectivity</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.Services\Microsoft.Toolkit.Uwp.Services.csproj">
|
||||
<Project>{7189a42d-6f1a-4fa3-8e00-e2c14fdf167a}</Project>
|
||||
<Name>Microsoft.Toolkit.Uwp.Services</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI.Controls\Microsoft.Toolkit.Uwp.UI.Controls.csproj">
|
||||
<Project>{e9faabfb-d726-42c1-83c1-cb46a29fea81}</Project>
|
||||
<Name>Microsoft.Toolkit.Uwp.UI.Controls</Name>
|
||||
|
|
|
@ -29,8 +29,11 @@ The [MasterDetailsView Control](https://docs.microsoft.com/dotnet/api/microsoft.
|
|||
|
||||
| Property | Type | Description |
|
||||
| -- | -- | -- |
|
||||
| BackButtonBehavior | BackButtonBehavior | Gets or sets the behavior to use for the back button. |
|
||||
| CompactModeThresholdWidth | double | If width of control is less than CompactModeThresholdWidth, the control will only display the master or details view - otherwise it will show both views. |
|
||||
| DetailsCommandBar | CommandBar | Gets or sets the Windows.UI.Xaml.Controls.CommandBar for the details section |
|
||||
| DetailsHeader | object | Gets or sets the content for the details pane's header |
|
||||
| DetailsHeaderTemplate | DataTemplate | Gets or sets the DataTemplate used to display the content of the details pane's header |
|
||||
| DetailsTemplate | DataTemplate | Gets or sets the DataTemplate used to display the details |
|
||||
| MapDetails | Func<object,object> | Gets or sets a function for mapping the selected item to a different model. This new model will be the DataContext of the Details area |
|
||||
| MasterCommandBar | CommandBar | Gets or sets the Windows.UI.Xaml.Controls.CommandBar for the master section |
|
||||
|
|
|
@ -58,7 +58,6 @@ Once you do a search, you should see a list similar to the one below (versions m
|
|||
* [Implicit Animations](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/ImplicitAnimations/)
|
||||
* [Light](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/Light/)
|
||||
* [Offset](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/Offset/)
|
||||
* [ParallaxService](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/ParallaxService/)
|
||||
* [ReorderGrid](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/ReorderGrid/)
|
||||
* [Rotate](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/Rotate/)
|
||||
* [Saturation](https://docs.microsoft.com/windows/uwpcommunitytoolkit/animations/Saturation/)
|
||||
|
@ -82,7 +81,6 @@ Once you do a search, you should see a list similar to the one below (versions m
|
|||
* [DropShadowPanel](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/DropShadowPanel/)
|
||||
* [Expander](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/Expander/)
|
||||
* [GridSplitter](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/GridSplitter/)
|
||||
* [HamburgerMenu](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/HamburgerMenu/)
|
||||
* [HeaderedContentControl](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/HeaderedContentControl/)
|
||||
* [HeaderedItemsControl](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/HeaderedItemsControl/)
|
||||
* [HeaderedTextBlock](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/HeaderedTextBlock/)
|
||||
|
@ -94,13 +92,11 @@ Once you do a search, you should see a list similar to the one below (versions m
|
|||
* [MasterDetailsView](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/MasterDetailsView/)
|
||||
* [Menu](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/Menu/)
|
||||
* [OrbitView](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/OrbitView/)
|
||||
* [PullToRefreshListView](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/PullToRefreshListview/)
|
||||
* [RadialGauge](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/RadialGauge/)
|
||||
* [RadialProgressBar](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/RadialProgressBar/)
|
||||
* [RangeSelector](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/RangeSelector/)
|
||||
* [RotatorTile](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/RotatorTile/)
|
||||
* [ScrollHeader](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/ScrollHeader/)
|
||||
* [SlideableListItem](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/SlidableListItem/)
|
||||
* [StaggeredPanel](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/StaggeredPanel/)
|
||||
* [TextToolbar](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/TextToolbar/)
|
||||
* [TileControl](https://docs.microsoft.com/windows/uwpcommunitytoolkit/controls/TileControl/)
|
||||
|
@ -116,7 +112,6 @@ Once you do a search, you should see a list similar to the one below (versions m
|
|||
* [ListViewExtensions](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/ListViewBase/)
|
||||
* [LogicalTree](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/LogicalTree/)
|
||||
* [MouseCursor](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/MouseCursor/)
|
||||
* [NavigationView Styles](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/NavigationView/)
|
||||
* [ScrollViewerExtensions](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/ScrollViewerExtensions/)
|
||||
* [SurfaceDialTextbox](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/SurfaceDialTextboxHelper/)
|
||||
* [TextBoxMask](https://docs.microsoft.com/windows/uwpcommunitytoolkit/extensions/TextBoxMask/)
|
||||
|
@ -148,7 +143,6 @@ Once you do a search, you should see a list similar to the one below (versions m
|
|||
* [WeakEventListener](https://docs.microsoft.com/windows/uwpcommunitytoolkit/helpers/WeakEventListener/)
|
||||
|
||||
### Services
|
||||
* [Bing](https://docs.microsoft.com/windows/uwpcommunitytoolkit/services/Bing/)
|
||||
* [Facebook](https://docs.microsoft.com/windows/uwpcommunitytoolkit/services/Facebook/)
|
||||
* [LinkedIn](https://docs.microsoft.com/windows/uwpcommunitytoolkit/services/Linkedin/)
|
||||
* [Microsoft Graph](https://docs.microsoft.com/windows/uwpcommunitytoolkit/services/MicrosoftGraph/)
|
||||
|
|