Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the "Description" column in Code Styles Options a "dataitem" control #18441

Merged
merged 1 commit into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/VisualStudio/Core/Impl/Options/GridOptionPreviewControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,25 @@
</GroupStyle>
</DataGrid.GroupStyle>
<DataGrid.Columns>
<DataGridTextColumn
<DataGridTemplateColumn
x:Name="description"
Header="{x:Static local:GridOptionPreviewControl.DescriptionHeader}"
Binding="{Binding Description, Mode=OneWay}"
Width="4.5*"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="{Binding DescriptionMargin, Converter={StaticResource MarginConverter}}" />
<Setter Property="Padding" Value="{StaticResource ResourceKey=cellPadding}" />
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="AutomationProperties.Name" Value="{Binding GroupName}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<local:TextBlockWithDataItemControlType
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left everything the same as the "Setter" elements before, with the exceptions of "Text", "AutomationProperties.Name", and "Focusable".

Text="{Binding Description, Mode=OneWay}"
Margin="{Binding DescriptionMargin, Converter={StaticResource MarginConverter}}"
Padding="{StaticResource ResourceKey=cellPadding}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
TextWrapping="Wrap"
AutomationProperties.Name="{Binding GroupNameAndDescription}"
Focusable="True"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
x:Name="preference"
Header="{x:Static local:GridOptionPreviewControl.PreferenceHeader}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal abstract class AbstractCodeStyleOptionViewModel : AbstractNotifyPropert
public string Description { get; set; }
public double DescriptionMargin { get; set; } = 12d;
public string GroupName { get; set; }
public string GroupNameAndDescription { get; set; }
public List<CodeStylePreference> Preferences { get; set; }
public List<NotificationOptionViewModel> NotificationPreferences { get; set; }

Expand Down Expand Up @@ -56,6 +57,7 @@ public AbstractCodeStyleOptionViewModel(
Preferences = preferences ?? GetDefaultPreferences();
NotificationPreferences = notificationPreferences ?? GetDefaultNotifications();
GroupName = groupName;
GroupNameAndDescription = $"{groupName}, {description}";
Copy link
Contributor Author

@dpoeschl dpoeschl Apr 4, 2017

Choose a reason for hiding this comment

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

We were getting around concatenating these before in a seriously ugly way. I can explain if needed. This is much better and actually sets the automation name to the full thing (whereas before we were just tricking Narrator into reading the right thing instead of setting the automation name correctly).

}

private static List<NotificationOptionViewModel> GetDefaultNotifications()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Windows.Automation.Peers;
using System.Windows.Controls;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
{
internal class TextBlockWithDataItemControlType : TextBlock
{
protected override AutomationPeer OnCreateAutomationPeer()
{
return new TextBlockWithDataItemControlTypeAutomationPeer(this);
}

private class TextBlockWithDataItemControlTypeAutomationPeer : TextBlockAutomationPeer
{
public TextBlockWithDataItemControlTypeAutomationPeer(TextBlock owner) : base(owner)
{
}

protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.DataItem;
}
}
}
}
1 change: 1 addition & 0 deletions src/VisualStudio/Core/Impl/ServicesVisualStudioImpl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
<DependentUpon>SymbolSpecificationDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Options\Style\NamingPreferences\SymbolSpecification\SymbolSpecificationViewModel.cs" />
<Compile Include="Options\TextBlockWithDataItemControlType.cs" />
<Compile Include="ProjectSystem\CPS\CPSProject.cs" />
<Compile Include="ProjectSystem\CPS\CPSCodeModelFactory.cs" />
<Compile Include="ProjectSystem\CPS\CPSProjectFactory.cs" />
Expand Down