mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-08 16:06:07 +02:00
Add article, code, toc, and redirects (#1343)
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="Application"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:CodeSampleVb"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Class Application
|
||||
|
||||
' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
|
||||
' can be handled in this file.
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,9 @@
|
||||
'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found.
|
||||
'1st parameter: where theme specific resource dictionaries are located
|
||||
'(used if a resource is not found in the page,
|
||||
' or application resource dictionaries)
|
||||
|
||||
'2nd parameter: where the generic resource dictionary is located
|
||||
'(used if a resource is not found in the page,
|
||||
'app, and any theme specific resource dictionaries)
|
||||
<Assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<RootNamespace>CodeSampleVb</RootNamespace>
|
||||
<NeutralLanguage>en-us</NeutralLanguage>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Import Include="System.Windows" />
|
||||
<Import Include="System.Windows.Controls" />
|
||||
<Import Include="System.Windows.Data" />
|
||||
<Import Include="System.Windows.Documents" />
|
||||
<Import Include="System.Windows.Input" />
|
||||
<Import Include="System.Windows.Media" />
|
||||
<Import Include="System.Windows.Media.Imaging" />
|
||||
<Import Include="System.Windows.Navigation" />
|
||||
<Import Include="System.Windows.Shapes" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<Window x:Class="MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:custom="clr-namespace:CodeSampleVb"
|
||||
Title="Object lifetime events" Height="100" Width="300">
|
||||
|
||||
<!--<LifetimeEventsXaml>-->
|
||||
<Canvas x:Name="canvas">
|
||||
<StackPanel x:Name="outerStackPanel" Initialized="InitHandler" Loaded="LoadHandler" Unloaded="UnloadHandler">
|
||||
<custom:ComponentWrapper x:Name="componentWrapper" Initialized="InitHandler" Loaded="LoadHandler" Unloaded="UnloadHandler">
|
||||
<TextBox x:Name="textBox1" Initialized="InitHandler" Loaded="LoadHandler" Unloaded="UnloadHandler" />
|
||||
<TextBox x:Name="textBox2" Initialized="InitHandler" Loaded="LoadHandler" Unloaded="UnloadHandler" />
|
||||
</custom:ComponentWrapper>
|
||||
</StackPanel>
|
||||
<Button Content="Remove canvas child elements" Click="Button_Click"/>
|
||||
</Canvas>
|
||||
<!--</LifetimeEventsXaml>-->
|
||||
|
||||
</Window>
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
'<LifetimeEventsCodeBehind>
|
||||
Partial Public Class MainWindow
|
||||
Inherits Window
|
||||
|
||||
Public Sub New()
|
||||
InitializeComponent()
|
||||
End Sub
|
||||
|
||||
' Handler for the Initialized lifetime event (attached in XAML).
|
||||
Private Sub InitHandler(sender As Object, e As EventArgs)
|
||||
Debug.WriteLine($"Initialized event on {CType(sender, FrameworkElement).Name}.")
|
||||
End Sub
|
||||
|
||||
' Handler for the Loaded lifetime event (attached in XAML).
|
||||
Private Sub LoadHandler(sender As Object, e As RoutedEventArgs)
|
||||
Debug.WriteLine($"Loaded event on {CType(sender, FrameworkElement).Name}.")
|
||||
End Sub
|
||||
|
||||
' Handler for the Unloaded lifetime event (attached in XAML).
|
||||
Private Sub UnloadHandler(sender As Object, e As RoutedEventArgs)
|
||||
Debug.WriteLine($"Unloaded event on {CType(sender, FrameworkElement).Name}.")
|
||||
End Sub
|
||||
|
||||
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
|
||||
' Remove nested controls.
|
||||
canvas.Children.Clear()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
' Custom control.
|
||||
Public Class ComponentWrapper
|
||||
Inherits ComponentWrapperBase
|
||||
End Class
|
||||
|
||||
' Custom base control.
|
||||
Public Class ComponentWrapperBase
|
||||
Inherits StackPanel
|
||||
|
||||
Public Sub New()
|
||||
' Attach handlers for the lifetime events.
|
||||
AddHandler Initialized, AddressOf InitHandler
|
||||
AddHandler Loaded, AddressOf LoadHandler
|
||||
AddHandler Unloaded, AddressOf UnloadHandler
|
||||
End Sub
|
||||
|
||||
' Handler for the Initialized lifetime event (attached in code-behind).
|
||||
Private Sub InitHandler(sender As Object, e As EventArgs)
|
||||
Debug.WriteLine("Initialized event on componentWrapperBase.")
|
||||
End Sub
|
||||
|
||||
' Handler for the Loaded lifetime event (attached in code-behind).
|
||||
Private Sub LoadHandler(sender As Object, e As RoutedEventArgs)
|
||||
Debug.WriteLine("Loaded event on componentWrapperBase.")
|
||||
End Sub
|
||||
|
||||
' Handler for the Unloaded lifetime event (attached in code-behind).
|
||||
Private Sub UnloadHandler(sender As Object, e As RoutedEventArgs)
|
||||
Debug.WriteLine("Unloaded event on componentWrapperBase.")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
'Output:
|
||||
'Initialized event on textBox1.
|
||||
'Initialized event on textBox2.
|
||||
'Initialized event on componentWrapperBase.
|
||||
'Initialized event on componentWrapper.
|
||||
'Initialized event on outerStackPanel.
|
||||
|
||||
'Loaded event on outerStackPanel.
|
||||
'Loaded event on componentWrapperBase.
|
||||
'Loaded event on componentWrapper.
|
||||
'Loaded event on textBox1.
|
||||
'Loaded event on textBox2.
|
||||
|
||||
'Unloaded event on outerStackPanel.
|
||||
'Unloaded event on componentWrapperBase.
|
||||
'Unloaded event on componentWrapper.
|
||||
'Unloaded event on textBox1.
|
||||
'Unloaded event on textBox2.
|
||||
'</LifetimeEventsCodeBehind>
|
||||
Reference in New Issue
Block a user