-
-
Notifications
You must be signed in to change notification settings - Fork 58
Add ColumnAutoWidthMode #361
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
Open
Mangepange
wants to merge
11
commits into
w-ahmad:main
Choose a base branch
from
Mangepange:feature_358_autosizing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b55b2b5
Add ColumnAutoWidthMode
e05c563
Adjust calculations
6f97d64
Move code
7b7a333
Adjust default and header width calculation
8d6d24a
Add sample page
de2697a
recalculate column widths when ColumnAutoWidthMode changes
w-ahmad 6f796b2
Rename ColumnAutoWidthMode to TableViewColumnAutoWidthMode
w-ahmad 6d67cda
Simplify ColumnSizingPage
w-ahmad 2fc287b
Merge branch 'main' into feature_358_autosizing
w-ahmad 10371e7
Potential fix for pull request finding
w-ahmad cd61b32
Potential fix for pull request finding
w-ahmad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
samples/WinUI.TableView.SampleApp/Pages/ColumnSizingPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <Page x:Class="WinUI.TableView.SampleApp.Pages.ColumnSizingPage" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:controls="using:WinUI.TableView.SampleApp.Controls" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:local="using:WinUI.TableView.SampleApp" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:tv="using:WinUI.TableView" | ||
| xmlns:ui="using:CommunityToolkit.WinUI" | ||
| d:DataContext="{d:DesignInstance Type=local:ExampleViewModel}" | ||
| mc:Ignorable="d" | ||
| DataContextChanged="OnDataContextChanged"> | ||
|
|
||
| <Grid> | ||
| <controls:SamplePresenter Description="This sample demonstrates the different ways a column can be sized." | ||
| Header="Column Sizing"> | ||
| <controls:SamplePresenter.Example> | ||
| <tv:TableView x:Name="tableView" | ||
| ItemsSource="{Binding Items}" /> | ||
| </controls:SamplePresenter.Example> | ||
| <controls:SamplePresenter.Options> | ||
| <StackPanel Spacing="16" | ||
| MinWidth="200"> | ||
| <ComboBox x:Name="columnAutoWidthMode" | ||
| HorizontalAlignment="Stretch" | ||
| Header="Column Auto Width Mode" | ||
| SelectedItem="{Binding ColumnAutoWidthMode, Mode=TwoWay, ElementName=tableView}" | ||
| ItemsSource="{ui:EnumValues Type=tv:TableViewColumnAutoWidthMode}" /> | ||
| </StackPanel> | ||
| </controls:SamplePresenter.Options> | ||
| <controls:SamplePresenter.Xaml> | ||
| <x:String xml:space="preserve"> | ||
| <tv:TableView ItemsSource="{Binding Items}" | ||
| ColumnAutoWidthMode="$(ColumnAutoWidthMode)"/> | ||
| </x:String> | ||
| </controls:SamplePresenter.Xaml> | ||
| <controls:SamplePresenter.Substitutions> | ||
| <controls:CodeSubstitution Key="ColumnAutoWidthMode" | ||
| Value="{x:Bind columnAutoWidthMode.SelectedItem, Mode=OneWay}" /> | ||
| </controls:SamplePresenter.Substitutions> | ||
| </controls:SamplePresenter> | ||
| </Grid> | ||
| </Page> |
20 changes: 20 additions & 0 deletions
20
samples/WinUI.TableView.SampleApp/Pages/ColumnSizingPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using Microsoft.UI.Xaml; | ||
| using Microsoft.UI.Xaml.Controls; | ||
|
|
||
| namespace WinUI.TableView.SampleApp.Pages; | ||
|
|
||
| public sealed partial class ColumnSizingPage : Page | ||
| { | ||
| public ColumnSizingPage() | ||
| { | ||
| InitializeComponent(); | ||
|
|
||
| } | ||
|
|
||
| private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) | ||
| { | ||
| if (DataContext is not ExampleViewModel viewModel) return; | ||
|
|
||
| viewModel.Items = [.. ExampleViewModel.ItemsList.Take(20)]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace WinUI.TableView; | ||
|
|
||
| /// <summary> | ||
| /// Specifies the behavior for automatic column width. | ||
| /// </summary> | ||
| public enum TableViewColumnAutoWidthMode | ||
| { | ||
| /// <summary> | ||
| /// Column width is adjusted to both header and maximum cell width. | ||
| /// </summary> | ||
| Both, | ||
|
|
||
| /// <summary> | ||
| /// Column width is adjusted to maximum cell width. | ||
| /// </summary> | ||
| Cells, | ||
|
|
||
| /// <summary> | ||
| /// Column width is adjusted to header width. | ||
| /// </summary> | ||
| Header | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.