Skip to content

Commit

Permalink
Merge branch 'main' into implementing-heading-level
Browse files Browse the repository at this point in the history
  • Loading branch information
ryalanms authored Jul 22, 2021
2 parents cee1558 + 3ffe8f2 commit cc7dfe9
Show file tree
Hide file tree
Showing 30 changed files with 420 additions and 155 deletions.
6 changes: 6 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in the repo,
# and will automatically be added as reviewers to all pull requests.
* @dotnet/wpf-developers
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@
<!-- Name -->
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Orientation="Horizontal">
<Label Style="{StaticResource LabelStyle}">Name:</Label>
<Label x:Name="NameLiveRegion" AutomationProperties.LiveSetting="Assertive" Style="{StaticResource LabelStyle}" Content="{Binding XPath=@Name}"></Label>
<Label x:Name="NameLiveRegion" AutomationProperties.LiveSetting="Assertive" Style="{StaticResource LabelStyle}" AutomationProperties.Name="{Binding XPath=@Name}" Content="{Binding XPath=@Name}"></Label>
</StackPanel>

<!-- Department -->
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal">
<Label Style="{StaticResource LabelStyle}">Department:</Label>
<Label Style="{StaticResource LabelStyle}" Content="{Binding XPath=@Department}"></Label>
<Label x:Name="DepartmentLiveRegion" AutomationProperties.LiveSetting="Assertive" Style="{StaticResource LabelStyle}" Content="{Binding XPath=@Department}" AutomationProperties.Name="{Binding XPath=@Department}"></Label>
</StackPanel>
<Grid Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Top" HorizontalAlignment="Left">

<!-- Expense type and Amount table -->
<DataGrid AutomationProperties.Name="Expense report" ItemsSource="{Binding XPath=Expense}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" AutoGenerateColumns="False" RowHeaderWidth="0" CanUserResizeColumns="False" CanUserResizeRows="False" >
<DataGrid AutomationProperties.Name="Expense report" ItemsSource="{Binding XPath=Expense}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" AutoGenerateColumns="False" HeadersVisibility="Column" CanUserResizeColumns="False" CanUserResizeRows="False" >
<DataGrid.Resources>
<!--
When using XmlDataProvider, we need to ensure the DataGridRow properly sets the automation name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e)
// the report for.
FrameworkElementAutomationPeer.FromElement(LiveRegion)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
FrameworkElementAutomationPeer.FromElement(NameLiveRegion)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
FrameworkElementAutomationPeer.FromElement(DepartmentLiveRegion)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<OutputType>WinExe</OutputType>
<RootNamespace>ExpenseIt9</RootNamespace>
Expand All @@ -13,4 +13,4 @@
<ItemGroup>
<Resource Include="watermark.png" />
</ItemGroup>
</Project>
</Project>
2 changes: 0 additions & 2 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
<configuration>
<packageSources>
<clear />
<add key="myget-fxlab" value="https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json" />
<add key="arcade" value="https://dotnetfeed.blob.core.windows.net/dotnet-tools-internal/index.json" />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="dotnet-coreclr" value="https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json" />
<add key="myget-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-wd" value="https://dotnetfeed.blob.core.windows.net/dotnet-windowsdesktop/index.json" />
<add key="aspnet-core" value="https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json" />
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ These samples require Visual Studio 2019 to build, test, and deploy, and also re
[.NET Core SDK](https://github.com/dotnet/core-sdk)

WPF on .NET Core 3.0 has been open-sourced, and is now available on [Github](https://github.com/dotnet/wpf)

**Note:** If you are using the latest version of Visual Studio 2019 (16.9.0 and above), the .NET Core 3 SDK must be downloaded and installed manually to successfully build these samples. You can find installers for the .NET Core 3 SDK at the [github](https://github.com/dotnet/core-sdk) or at <https://dot.net/core>

## Using the samples

Expand All @@ -51,6 +53,6 @@ The easiest way to use these samples without using Git is to download the zip fi
**Notes:**
* Before you unzip the archive, right-click it, select Properties, and then select Unblock.
* Most samples should work independently
* By default, all the samples target .NET core 3.0.
* By default, all the samples target .NET core 3.0. (Installers for the .NET core 3 SDK can be found at <https://dot.net/core>)

For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, please refer to the guidance available in [MSDN](https://msdn.microsoft.com/en-us/library/ms754130.aspx). These samples are provided as-is in order to indicate or demonstrate the functionality of the programming models and feature APIs for WPF.
10 changes: 10 additions & 0 deletions Sample Applications/CustomComboBox/DropList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ public IEnumerable<object> ItemsSource
DependencyProperty.Register("ItemsSource", typeof(IEnumerable<object>), typeof(DropList));


public Style ItemContainerStyle
{
get { return (Style)GetValue(ItemContainerStyleProperty); }
set { SetValue(ItemContainerStyleProperty, value); }

}

public static readonly DependencyProperty ItemContainerStyleProperty =
DependencyProperty.Register("ItemContainerStyle", typeof(Style), typeof(DropList));

public string DisplayMemberPath
{
get { return (string)GetValue(DisplayMemberPathProperty); }
Expand Down
118 changes: 118 additions & 0 deletions Sample Applications/CustomComboBox/ExpandableToggleButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace CustomComboBox
{
public class ExpandableToggleButton : Button
{
private ExpandableToggleButtonAutomationPeer peer;

private ExpandCollapseState state = ExpandCollapseState.Collapsed;

public static readonly RoutedEvent ExpandedEvent = EventManager.RegisterRoutedEvent("Expanded", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ExpandableToggleButton));

public static readonly RoutedEvent CollapsedEvent = EventManager.RegisterRoutedEvent("Collapsed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ExpandableToggleButton));

public event RoutedEventHandler Expanded
{
add { AddHandler(ExpandedEvent, value); }
remove { RemoveHandler(ExpandedEvent, value); }
}

public event RoutedEventHandler Collapsed
{
add { AddHandler(CollapsedEvent, value); }
remove { RemoveHandler(CollapsedEvent, value); }
}

public ExpandCollapseState State
{
get
{
return this.state;
}
set
{
ExpandCollapseState previousState = this.state;

this.state = value;

if ((this.peer != null) && this.state != previousState)
{
this.peer.RaisePropertyChangedEvent(
ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty,
previousState,
this.state);
if(this.state == ExpandCollapseState.Collapsed)
{
RoutedEventArgs collapsedEventArgs = new RoutedEventArgs(CollapsedEvent);
RaiseEvent(collapsedEventArgs);
} else
{
RoutedEventArgs expandedEventArgs = new RoutedEventArgs(ExpandedEvent);
RaiseEvent(expandedEventArgs);
}
}
}
}

protected override AutomationPeer OnCreateAutomationPeer()
{
if(this.peer == null)
{
this.peer = new ExpandableToggleButtonAutomationPeer(this);
}

return this.peer;
}

protected override void OnClick()
{
this.State = (this.State == ExpandCollapseState.Collapsed ? ExpandCollapseState.Expanded :
ExpandCollapseState.Collapsed);

// base.OnClick();
}
}

public class ExpandableToggleButtonAutomationPeer : ButtonAutomationPeer, IExpandCollapseProvider
{
private ExpandableToggleButton Button { get { return Owner as ExpandableToggleButton; } }

public ExpandableToggleButtonAutomationPeer(ExpandableToggleButton owner) : base(owner) {}

public override object GetPattern(PatternInterface patternInterface)
{
if(patternInterface == PatternInterface.ExpandCollapse)
{
return this;
}
return base.GetPattern(patternInterface);
}

public ExpandCollapseState ExpandCollapseState
{
get
{
return Button.State;
}
}

public void Expand()
{
Button.State = ExpandCollapseState.Expanded;
}

public void Collapse()
{
Button.State = ExpandCollapseState.Collapsed;
}
}
}
7 changes: 4 additions & 3 deletions Sample Applications/CustomComboBox/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
HorizontalAlignment="Center" VerticalAlignment="Top"
Style="{StaticResource DropListStyle}"
ItemsSource="{Binding Movies}" Command="{Binding OnWatchNow}"
ItemContainerStyle="{StaticResource MovieItemContainerStyle}"
DisplayMemberPath="Title"
IsTabStop="False"/>
IsTabStop="False" Width="160"/>

<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="{Binding SelectedMovie, Converter={StaticResource stringConverter}, ConverterParameter=text}" Style="{DynamicResource streamingTextStyle}"/>
<TextBlock Text="{Binding SelectedMovie}" HorizontalAlignment="Center" />
<TextBlock Text="{Binding SelectedMovie, Converter={StaticResource stringConverter}, ConverterParameter=text, NotifyOnTargetUpdated=True}" Style="{DynamicResource streamingTextStyle}" TargetUpdated="TextBlock_TargetUpdated" AutomationProperties.LiveSetting="Assertive"/>
<TextBlock Text="{Binding SelectedMovie, NotifyOnTargetUpdated=True}" HorizontalAlignment="Center" TargetUpdated="TextBlock_TargetUpdated" AutomationProperties.LiveSetting="Assertive"/>
</StackPanel>
</Grid>
</Window>
13 changes: 13 additions & 0 deletions Sample Applications/CustomComboBox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
Expand All @@ -28,5 +29,17 @@ public MainWindow()
private void Button_Click(object sender, RoutedEventArgs e)
{
}

private void TextBlock_TargetUpdated(object sender, DataTransferEventArgs e)
{
if (e.Property == TextBlock.TextProperty)
{
var textBlockPeer = UIElementAutomationPeer.FromElement(sender as TextBlock);
if(textBlockPeer != null)
{
textBlockPeer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
}
}
}
}
}
Loading

0 comments on commit cc7dfe9

Please sign in to comment.