data trigger
This commit is contained in:
9
PacticeSolution/DataTriggerSample/App.xaml
Normal file
9
PacticeSolution/DataTriggerSample/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="DataTriggerSample.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:DataTriggerSample"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
17
PacticeSolution/DataTriggerSample/App.xaml.cs
Normal file
17
PacticeSolution/DataTriggerSample/App.xaml.cs
Normal file
@@ -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 DataTriggerSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
10
PacticeSolution/DataTriggerSample/AssemblyInfo.cs
Normal file
10
PacticeSolution/DataTriggerSample/AssemblyInfo.cs
Normal file
@@ -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)
|
||||
)]
|
10
PacticeSolution/DataTriggerSample/DataTriggerSample.csproj
Normal file
10
PacticeSolution/DataTriggerSample/DataTriggerSample.csproj
Normal file
@@ -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>
|
65
PacticeSolution/DataTriggerSample/MainWindow.xaml
Normal file
65
PacticeSolution/DataTriggerSample/MainWindow.xaml
Normal file
@@ -0,0 +1,65 @@
|
||||
<Window x:Class="DataTriggerSample.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:DataTriggerSample"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="400" Width="400">
|
||||
<Window.Resources>
|
||||
<Style x:Key="styTextBlock" TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=cboMain, Path=IsChecked}" Value="True">
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="styProgressBar" TargetType="ProgressBar">
|
||||
<Setter Property="Foreground" Value="Green"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=pbMain, Path=Value}" Value="100">
|
||||
<Setter Property="Foreground" Value="Red"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0">
|
||||
<CheckBox x:Name="cboMain" Content="Click me!" FontSize="20"/>
|
||||
<TextBlock Text="Hello WFP!" FontSize="20"
|
||||
Style="{StaticResource styTextBlock}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<Slider x:Name="sldMain" Margin="10"
|
||||
Minimum="0" Maximum="100"/>
|
||||
<ProgressBar x:Name="pbMain" Height="10" Margin="10"
|
||||
Minimum="0" Maximum="100"
|
||||
Value="{Binding ElementName=sldMain, Path=Value}"
|
||||
Style="{StaticResource styProgressBar}"/>
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
Text="{Binding ElementName=sldMain, Path=Value}"/>
|
||||
<ProgressBar x:Name="pbSub" Height="30" Margin="10"
|
||||
Minimum="0" Maximum="100"
|
||||
Value="{Binding ElementName=sldMain, Path=Value}">
|
||||
<ProgressBar.Style>
|
||||
<Style TargetType="ProgressBar">
|
||||
<Setter Property="Foreground" Value="Blue"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=pbMain, Path=Value}" Value="100">
|
||||
<Setter Property="Foreground" Value="MediumPurple"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ProgressBar.Style>
|
||||
</ProgressBar>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
28
PacticeSolution/DataTriggerSample/MainWindow.xaml.cs
Normal file
28
PacticeSolution/DataTriggerSample/MainWindow.xaml.cs
Normal file
@@ -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 DataTriggerSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListSample", "ListSample\Li
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PropertyTriggerSample", "PropertyTriggerSample\PropertyTriggerSample.csproj", "{480DC5E9-1E18-4176-B964-FD2024C5F1C1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataTriggerSample", "DataTriggerSample\DataTriggerSample.csproj", "{2184CBCF-A59E-4C6F-9BBF-1DC20F132B50}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -177,6 +179,10 @@ Global
|
||||
{480DC5E9-1E18-4176-B964-FD2024C5F1C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{480DC5E9-1E18-4176-B964-FD2024C5F1C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{480DC5E9-1E18-4176-B964-FD2024C5F1C1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2184CBCF-A59E-4C6F-9BBF-1DC20F132B50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2184CBCF-A59E-4C6F-9BBF-1DC20F132B50}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2184CBCF-A59E-4C6F-9BBF-1DC20F132B50}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2184CBCF-A59E-4C6F-9BBF-1DC20F132B50}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Reference in New Issue
Block a user