grid(panel) shared size

main
syneffort 2 years ago
parent 372c2948dd
commit 0132203f24
  1. 9
      PacticeSolution/BindingSample/App.xaml
  2. 17
      PacticeSolution/BindingSample/App.xaml.cs
  3. 10
      PacticeSolution/BindingSample/AssemblyInfo.cs
  4. 10
      PacticeSolution/BindingSample/BindingSample.csproj
  5. 46
      PacticeSolution/BindingSample/MainWindow.xaml
  6. 28
      PacticeSolution/BindingSample/MainWindow.xaml.cs
  7. 55
      PacticeSolution/BindingSample/Model/Customer.cs
  8. 14
      PacticeSolution/BindingSample/Model/Customers.cs
  9. 9
      PacticeSolution/GridSharedSample/App.xaml
  10. 17
      PacticeSolution/GridSharedSample/App.xaml.cs
  11. 10
      PacticeSolution/GridSharedSample/AssemblyInfo.cs
  12. 10
      PacticeSolution/GridSharedSample/GridSharedSample.csproj
  13. 76
      PacticeSolution/GridSharedSample/MainWindow.xaml
  14. 28
      PacticeSolution/GridSharedSample/MainWindow.xaml.cs
  15. 26
      PacticeSolution/PacticeSolution.sln

@ -0,0 +1,9 @@
<Application x:Class="BindingSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BindingSample"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace BindingSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

@ -0,0 +1,46 @@
<Window x:Class="BindingSample.MainWindow"
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:local="clr-namespace:BindingSample"
xmlns:model="clr-namespace:BindingSample.Model"
mc:Ignorable="d"
Title="MainWindow" Height="500" Width="500">
<Window.Resources>
<model:Customers x:Key="rscCustomer">
<model:Customer Name="Richard" Tel="010-0000-0000"/>
<model:Customer Name="Jackson" Tel="010-1111-1111"/>
<model:Customer Name="Tylor" Tel="010-2222-2222"/>
<model:Customer Name="Sydney" Tel="010-3333-3333"/>
</model:Customers>
<Style x:Key="styTextBlock" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</Window.Resources>
<Grid x:Name="rgdMain" Margin="10" DataContext="{StaticResource rscCustomer}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="Name: " Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="0" Margin="10"
Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Column="2" Grid.Row="0" Content="Tel: " Margin="10"/>
<TextBox Grid.Column="3" Grid.Row="0" Margin="10"
Text="{Binding Tel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Window>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace BindingSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BindingSample.Model
{
internal class Customer : INotifyPropertyChanged
{
private string _name;
private string _tel;
public event PropertyChangedEventHandler? PropertyChanged;
public Customer() : this("Name", "Tel")
{
}
public Customer(string name, string tel)
{
_name = name;
_tel = tel;
}
public string Name
{
get { return _name; }
set
{
_name = value;
OnPropertyChanged(nameof(Name));
}
}
public string Tel
{
get { return _tel; }
set
{
_tel = value;
OnPropertyChanged(nameof(Tel));
}
}
private void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BindingSample.Model
{
internal class Customers : ObservableCollection<Customer>
{
}
}

@ -0,0 +1,9 @@
<Application x:Class="GridSharedSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GridSharedSample"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace GridSharedSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

@ -0,0 +1,76 @@
<Window x:Class="GridSharedSample.MainWindow"
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:local="clr-namespace:GridSharedSample"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<DockPanel Margin="10" Grid.IsSharedSizeScope="True">
<Grid DockPanel.Dock="Top" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="ssgBookNumber"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="ssgPublisher"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="ssgPrics"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Background="LightSteelBlue" BorderBrush="DarkGray" BorderThickness="1" Padding="5">
<TextBlock Text="Book No." HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Grid.Row="0" Background="LightSteelBlue" BorderBrush="DarkGray" BorderThickness="1" Padding="5">
<TextBlock Text="Book name" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="2" Grid.Row="0" Background="LightSteelBlue" BorderBrush="DarkGray" BorderThickness="1" Padding="5">
<TextBlock Text="Publisher" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="3" Grid.Row="0" Background="LightSteelBlue" BorderBrush="DarkGray" BorderThickness="1" Padding="5">
<TextBlock Text="Price" HorizontalAlignment="Center"/>
</Border>
<FrameworkElement Grid.Column="4" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
</Grid>
<ScrollViewer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="ssgBookNumber"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="ssgPublisher"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="ssgPrics"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="1"/>
<TextBlock Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="WPF"/>
<TextBlock Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="MSFT"/>
<TextBlock Grid.Column="3" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="150"/>
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="2"/>
<TextBlock Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="WinForm"/>
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="MSFT"/>
<TextBlock Grid.Column="3" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="500"/>
<TextBlock Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="3"/>
<TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Elder's Scroll"/>
<TextBlock Grid.Column="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="BETHESDA"/>
<TextBlock Grid.Column="3" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="999,999,999"/>
<TextBlock Grid.Column="0" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="4"/>
<TextBlock Grid.Column="1" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Treasure Map"/>
<TextBlock Grid.Column="2" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Unknown"/>
<TextBlock Grid.Column="3" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="999,999,999,999,999,999"/>
</Grid>
</ScrollViewer>
</DockPanel>
</Window>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GridSharedSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

@ -25,19 +25,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMButtonControl", "MVVMBu
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataGridEventTriggerSample", "DataGridEventTriggerSample\DataGridEventTriggerSample.csproj", "{48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataGridEventTriggerSample", "DataGridEventTriggerSample\DataGridEventTriggerSample.csproj", "{48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMDataGridBinding", "MVVMDataGridBinding\MVVMDataGridBinding.csproj", "{22B968EB-0566-474B-8B1C-105E24727638}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMDataGridBinding", "MVVMDataGridBinding\MVVMDataGridBinding.csproj", "{22B968EB-0566-474B-8B1C-105E24727638}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageLoader", "ImageLoader\ImageLoader.csproj", "{F65ED213-2F48-4370-B327-FC1F4AFF1E66}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageLoader", "ImageLoader\ImageLoader.csproj", "{F65ED213-2F48-4370-B327-FC1F4AFF1E66}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlUISample", "XamlUISample\XamlUISample.csproj", "{CBB0126E-291E-47F0-82D4-B7D78439BC4C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XamlUISample", "XamlUISample\XamlUISample.csproj", "{CBB0126E-291E-47F0-82D4-B7D78439BC4C}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyPropertySample", "DependencyProperty\DependencyPropertySample.csproj", "{7DED7470-62BB-4042-B161-98F9605046B2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyPropertySample", "DependencyProperty\DependencyPropertySample.csproj", "{7DED7470-62BB-4042-B161-98F9605046B2}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMComboBoxSample", "MVVMComboBoxSample\MVVMComboBoxSample.csproj", "{86DDE4C6-1359-4EB7-BEE6-13EC137F081D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMComboBoxSample", "MVVMComboBoxSample\MVVMComboBoxSample.csproj", "{86DDE4C6-1359-4EB7-BEE6-13EC137F081D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlTemplateSample", "ControlTemplateSample\ControlTemplateSample.csproj", "{F96483CE-6056-4DC5-8802-CE663BACB4B4}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlTemplateSample", "ControlTemplateSample\ControlTemplateSample.csproj", "{F96483CE-6056-4DC5-8802-CE663BACB4B4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentProperty", "ContentProperty\ContentProperty.csproj", "{26DCE4C7-777A-42D4-8475-CAF9A0DC6781}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContentProperty", "ContentProperty\ContentProperty.csproj", "{26DCE4C7-777A-42D4-8475-CAF9A0DC6781}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BindingSample", "BindingSample\BindingSample.csproj", "{E7E2D1BF-97F5-4C77-8F96-D2882805EFF5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridSharedSample", "GridSharedSample\GridSharedSample.csproj", "{32927DD0-81D5-48C7-BA39-3446651DF897}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -117,6 +121,14 @@ Global
{26DCE4C7-777A-42D4-8475-CAF9A0DC6781}.Debug|Any CPU.Build.0 = Debug|Any CPU {26DCE4C7-777A-42D4-8475-CAF9A0DC6781}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26DCE4C7-777A-42D4-8475-CAF9A0DC6781}.Release|Any CPU.ActiveCfg = Release|Any CPU {26DCE4C7-777A-42D4-8475-CAF9A0DC6781}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26DCE4C7-777A-42D4-8475-CAF9A0DC6781}.Release|Any CPU.Build.0 = Release|Any CPU {26DCE4C7-777A-42D4-8475-CAF9A0DC6781}.Release|Any CPU.Build.0 = Release|Any CPU
{E7E2D1BF-97F5-4C77-8F96-D2882805EFF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7E2D1BF-97F5-4C77-8F96-D2882805EFF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7E2D1BF-97F5-4C77-8F96-D2882805EFF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7E2D1BF-97F5-4C77-8F96-D2882805EFF5}.Release|Any CPU.Build.0 = Release|Any CPU
{32927DD0-81D5-48C7-BA39-3446651DF897}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32927DD0-81D5-48C7-BA39-3446651DF897}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32927DD0-81D5-48C7-BA39-3446651DF897}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32927DD0-81D5-48C7-BA39-3446651DF897}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Loading…
Cancel
Save