mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 00:56:03 +02:00
Migrate code;widen xaml snip ref (#1279)
This commit is contained in:
+3
-3
@@ -16,12 +16,12 @@ This example shows how to use the methods in the <xref:System.Windows.Controls.C
|
||||
## Example
|
||||
The following example creates a <xref:System.Windows.Controls.Grid> element with a <xref:System.Windows.FrameworkElement.Name%2A> of `grid1`. The <xref:System.Windows.Controls.Grid> contains a <xref:System.Windows.Controls.StackPanel> that holds <xref:System.Windows.Controls.Button> elements, each controlled by a different collection method. When you click a <xref:System.Windows.Controls.Button>, it activates a method call in the code-behind file.
|
||||
|
||||
[!code-xaml[ColumnDefinitionsGrid#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ColumnDefinitionsGrid/CSharp/Window1.xaml#1)]
|
||||
:::code language="xaml" source="snippets/manipulate-columns-and-rows-by-using-columndefinitionscollections/csharp/Window1.xaml" id="Snippet1":::
|
||||
|
||||
This example defines a series of custom methods, each corresponding to a <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event in the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] file. You can change the number of columns and rows in the <xref:System.Windows.Controls.Grid> in several ways, which includes adding or removing rows and columns; and counting the total number of rows and columns. To prevent <xref:System.ArgumentOutOfRangeException> and <xref:System.ArgumentException> exceptions, you can use the error-checking functionality that the <xref:System.Windows.Controls.ColumnDefinitionCollection.RemoveRange%2A> method provides.
|
||||
|
||||
[!code-csharp[ColumnDefinitionsGrid#2](~/samples/snippets/csharp/VS_Snippets_Wpf/ColumnDefinitionsGrid/CSharp/Window1.xaml.cs#2)]
|
||||
[!code-vb[ColumnDefinitionsGrid#2](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ColumnDefinitionsGrid/VisualBasic/Window1.xaml.vb#2)]
|
||||
:::code language="csharp" source="snippets/manipulate-columns-and-rows-by-using-columndefinitionscollections/csharp/Window1.xaml.cs" id="Snippet2":::
|
||||
:::code language="vb" source="snippets/manipulate-columns-and-rows-by-using-columndefinitionscollections/vb/Window1.xaml.vb" id="Snippet2":::
|
||||
|
||||
## See also
|
||||
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="columndefinitions_grid.Window1"
|
||||
Title="ColumnDefinitions Sample">
|
||||
<Border BorderBrush="Black" Background="White" BorderThickness="2">
|
||||
<!-- <Snippet1> -->
|
||||
<DockPanel Margin="10,0,0,0">
|
||||
|
||||
<TextBlock FontSize="20" FontWeight="Bold" DockPanel.Dock="Top">Grid Column and Row Collections</TextBlock>
|
||||
<TextBlock DockPanel.Dock="Top">Click any of the buttons below to invoke the associated methods and properties of ColumnDefinition and RowDefinition Collections.</TextBlock>
|
||||
<Grid DockPanel.Dock="Top" HorizontalAlignment="Left" Name="grid1" ShowGridLines="true" Width="625" Height="400" Background="#b0e0e6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
</Grid>
|
||||
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
|
||||
<Button Width="125" Click="addCol">Add Column</Button>
|
||||
<Button Width="125" Click="addRow">Add Row</Button>
|
||||
<Button Width="125" Click="clearCol">Clear All Columns</Button>
|
||||
<Button Width="125" Click="clearRow">Clear All Rows</Button>
|
||||
<Button Width="125" Click="removeCol">Remove One Column</Button>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
|
||||
<Button Width="125" Click="removeRow">Remove One Row</Button>
|
||||
<Button Width="125" Click="colCount">How Many Columns?</Button>
|
||||
<Button Width="125" Click="rowCount">How Many Rows?</Button>
|
||||
<Button Width="125" Click="rem5Col">Remove 5 Columns</Button>
|
||||
<Button Width="125" Click="rem5Row">Remove 5 Rows</Button>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
|
||||
<Button Width="125" Click="containsRow">Contains Row?</Button>
|
||||
<Button Width="125" Click="containsCol">Contains Column?</Button>
|
||||
<Button Width="125" Click="insertRowAt">Insert Row</Button>
|
||||
<Button Width="125" Click="insertColAt">Insert Column</Button>
|
||||
<Button Width="125" Click="colReadOnly">IsReadOnly?</Button>
|
||||
</StackPanel>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp1"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp2"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp3"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp4"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp5"/>
|
||||
</DockPanel>
|
||||
<!-- </Snippet1> -->
|
||||
</Border>
|
||||
</Window>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
+11
-3
@@ -1,14 +1,19 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>SDKSample</AssemblyName>
|
||||
<TargetType>winexe</TargetType>
|
||||
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<ProjectGuid>{4BDD3A99-C878-405A-9108-7C948EA50659}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -44,4 +49,7 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"host": "visualstudio"
|
||||
}
|
||||
+11
-3
@@ -1,14 +1,19 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>SDKSample</AssemblyName>
|
||||
<TargetType>winexe</TargetType>
|
||||
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<ProjectGuid>{9CD74B47-FC44-43A0-B18E-FFF7B4EA3EF8}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<ItemGroup>
|
||||
@@ -39,4 +44,7 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.diagnostics>
|
||||
<sources>
|
||||
<!-- This section defines the logging configuration for My.Application.Log -->
|
||||
<source name="DefaultSource" switchName="DefaultSwitch">
|
||||
<listeners>
|
||||
<add name="FileLog"/>
|
||||
<!-- Uncomment the below section to write to the Application Event Log -->
|
||||
<!--<add name="EventLog"/>-->
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<switches>
|
||||
<add name="DefaultSwitch" value="Information"/>
|
||||
</switches>
|
||||
<sharedListeners>
|
||||
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
|
||||
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
|
||||
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
|
||||
</sharedListeners>
|
||||
</system.diagnostics>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"host": "visualstudio"
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="columndefinitions_grid.Window1"
|
||||
Title="ColumnDefinitions Sample">
|
||||
<Border BorderBrush="Black" Background="White" BorderThickness="2">
|
||||
<DockPanel Margin="10,0,0,0">
|
||||
|
||||
<TextBlock FontSize="20" FontWeight="Bold" DockPanel.Dock="Top">Grid Column and Row Collections</TextBlock>
|
||||
<TextBlock DockPanel.Dock="Top">Click any of the buttons below to invoke the associated methods and properties of ColumnDefinition and RowDefinition Collections.</TextBlock>
|
||||
<!-- <Snippet1> -->
|
||||
<Grid DockPanel.Dock="Top" HorizontalAlignment="Left" Name="grid1" ShowGridLines="true" Width="625" Height="400" Background="#b0e0e6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
</Grid>
|
||||
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
|
||||
<Button Width="125" Click="addCol">Add Column</Button>
|
||||
<Button Width="125" Click="addRow">Add Row</Button>
|
||||
<Button Width="125" Click="clearCol">Clear All Columns</Button>
|
||||
<Button Width="125" Click="clearRow">Clear All Rows</Button>
|
||||
<Button Width="125" Click="removeCol">Remove One Column</Button>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
|
||||
<Button Width="125" Click="removeRow">Remove One Row</Button>
|
||||
<Button Width="125" Click="colCount">How Many Columns?</Button>
|
||||
<Button Width="125" Click="rowCount">How Many Rows?</Button>
|
||||
<Button Width="125" Click="rem5Col">Remove 5 Columns</Button>
|
||||
<Button Width="125" Click="rem5Row">Remove 5 Rows</Button>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
|
||||
<Button Width="125" Click="containsRow">Contains Row?</Button>
|
||||
<Button Width="125" Click="containsCol">Contains Column?</Button>
|
||||
<Button Width="125" Click="insertRowAt">Insert Row</Button>
|
||||
<Button Width="125" Click="insertColAt">Insert Column</Button>
|
||||
<Button Width="125" Click="colReadOnly">IsReadOnly?</Button>
|
||||
</StackPanel>
|
||||
<!-- </Snippet1> -->
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp1"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp2"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp3"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp4"/>
|
||||
<TextBlock DockPanel.Dock="Top" Name="tp5"/>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user