mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-08 16:06:07 +02:00
Content update - Dependency properties overview (user story 1878471) (#1160)
* Update article and code projects * Further edits * Fix links * Relocate article & snippets to wpf/properties folder * add toc and redirects * Add acrolinx comment and make a minor edit. * minor Co-authored-by: Andy De George (adegeo) <[email protected]>
This commit is contained in:
co-authored by
Andy De George
parent
bdd178c010
commit
57b6ca1593
+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
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
Imports System.Windows
|
||||
|
||||
'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)>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<RootNamespace>CodeSampleVb</RootNamespace>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="stripes.jpg" />
|
||||
<None Remove="test.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="stripes.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="test.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<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>
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
<Window x:Class="CodeSampleVb.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"
|
||||
mc:Ignorable="d"
|
||||
Title="Dependency Properties" Height="220" Width="300">
|
||||
<Window.Resources>
|
||||
<XmlDataProvider x:Key="TestData" Source="test.xml" XPath="tests"/>
|
||||
|
||||
<!--<SimpleStyleDefinition>-->
|
||||
<Style x:Key="GreenButtonStyle">
|
||||
<Setter Property="Control.Background" Value="Green"/>
|
||||
</Style>
|
||||
<!--</SimpleStyleDefinition>-->
|
||||
|
||||
</Window.Resources>
|
||||
<StackPanel>
|
||||
|
||||
<!--<Resource>-->
|
||||
<StackPanel.Resources>
|
||||
<SolidColorBrush x:Key="MyBrush" Color="Gold"/>
|
||||
</StackPanel.Resources>
|
||||
<!--</Resource>-->
|
||||
|
||||
<!--<BasicPropertySyntax>-->
|
||||
<Button Content="I am red" Background="Red"/>
|
||||
<!--</BasicPropertySyntax>-->
|
||||
|
||||
<!--<PropertyElementSyntax>-->
|
||||
<Button Content="I have an image background">
|
||||
<Button.Background>
|
||||
<ImageBrush ImageSource="stripes.jpg"/>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<!--</PropertyElementSyntax>-->
|
||||
|
||||
<!--<ResourceReference>-->
|
||||
<Button Background="{DynamicResource MyBrush}" Content="I am gold" />
|
||||
<!--</ResourceReference>-->
|
||||
|
||||
<!--<BasicInlineBinding>-->
|
||||
<Button Content="{Binding Source={StaticResource TestData}, XPath=test[1]/@text}"/>
|
||||
<!--</BasicInlineBinding>-->
|
||||
|
||||
<!--<SimpleStyle>-->
|
||||
<Button Style="{StaticResource GreenButtonStyle}" Content="I am green"/>
|
||||
<!--</SimpleStyle>-->
|
||||
|
||||
<!--<Animate>-->
|
||||
<Button Content="I am animated">
|
||||
<Button.Background>
|
||||
<SolidColorBrush x:Name="AnimBrush"/>
|
||||
</Button.Background>
|
||||
<Button.Triggers>
|
||||
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<ColorAnimation
|
||||
Storyboard.TargetName="AnimBrush"
|
||||
Storyboard.TargetProperty="(SolidColorBrush.Color)"
|
||||
From="Blue" To="White" Duration="0:0:1"
|
||||
AutoReverse="True" RepeatBehavior="Forever" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Button.Triggers>
|
||||
</Button>
|
||||
<!--</Animate>-->
|
||||
|
||||
<!--<InheritanceBindingContext>-->
|
||||
<StackPanel Canvas.Top="50" DataContext="{Binding Source={StaticResource TestData}}">
|
||||
<Button Content="{Binding XPath=test[2]/@text}"/>
|
||||
</StackPanel>
|
||||
<!--</InheritanceBindingContext>-->
|
||||
|
||||
<!--<PropertyValuePrecedence>-->
|
||||
<StackPanel>
|
||||
<StackPanel.Resources>
|
||||
<Style x:Key="{x:Type Button}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="Orange"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Button>I am styled orange</Button>
|
||||
<Button Background="Pink">I am locally set to pink (not styled orange)</Button>
|
||||
</StackPanel>
|
||||
<!--</PropertyValuePrecedence>-->
|
||||
|
||||
</StackPanel>
|
||||
</Window>
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
Namespace CodeSampleVb
|
||||
Partial Public Class MainWindow
|
||||
Inherits Window
|
||||
|
||||
Public Sub New()
|
||||
InitializeComponent()
|
||||
|
||||
' <ProceduralPropertySet>
|
||||
Dim myButton As New Button With {
|
||||
.Width = 200.0
|
||||
}
|
||||
' </ProceduralPropertySet>
|
||||
|
||||
' <ProceduralPropertyGet>
|
||||
Dim whatWidth As Double = myButton.Width
|
||||
' </ProceduralPropertyGet>
|
||||
|
||||
End Sub
|
||||
|
||||
' <DefineDependencyProperty>
|
||||
Public Shared ReadOnly IsSpinningProperty As DependencyProperty =
|
||||
DependencyProperty.Register("IsSpinning", GetType(Boolean), GetType(MainWindow))
|
||||
|
||||
Public Property IsSpinning As Boolean
|
||||
Get
|
||||
Return GetValue(IsSpinningProperty)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
SetValue(IsSpinningProperty, value)
|
||||
End Set
|
||||
End Property
|
||||
' </DefineDependencyProperty>
|
||||
|
||||
End Class
|
||||
|
||||
' <OverrideMetadata>
|
||||
Public Class SpinnerControl
|
||||
Inherits ItemsControl
|
||||
Shared Sub New()
|
||||
DefaultStyleKeyProperty.OverrideMetadata(GetType(SpinnerControl), New FrameworkPropertyMetadata(GetType(SpinnerControl)))
|
||||
End Sub
|
||||
End Class
|
||||
' </OverrideMetadata>
|
||||
|
||||
End Namespace
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
+4
@@ -0,0 +1,4 @@
|
||||
<tests>
|
||||
<test text="I have data binding content"/>
|
||||
<test text="I have inherited data binding content"/>
|
||||
</tests>
|
||||
Reference in New Issue
Block a user