[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
using System.ComponentModel; namespace SilverlightDataTriggerDemo { public class MyViewModel:ViewModel { private bool isViewModelEnabled; public bool IsViewModelEnabled { get { return isViewModelEnabled; } set { isViewModelEnabled = value; NotifyPropertyChanged("IsViewModelEnabled"); } } } public class ViewModel:INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { }; protected void NotifyPropertyChanged(string propertyName) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } }
<UserControl x:Class="SilverlightDataTriggerDemo.MainPage" 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:vm="clr-namespace:SilverlightDataTriggerDemo" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <vm:MyViewModel x:Key="viewModel"/> </UserControl.Resources> <CheckBox DataContext="{StaticResource viewModel}" IsChecked="{Binding IsViewModelEnabled, Mode=TwoWay}"> <TextBlock> <i:Interaction.Triggers> <ei:DataTrigger Binding="{Binding IsViewModelEnabled}" Value="true"> <ei:ChangePropertyAction PropertyName="Text" Value="Changed!!"/> </ei:DataTrigger> </i:Interaction.Triggers> </TextBlock> </CheckBox> </UserControl>
<UserControl x:Class="SilverlightDataTriggerDemo.MainPage" 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:vm="clr-namespace:SilverlightDataTriggerDemo" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <vm:MyViewModel x:Key="viewModel"/> </UserControl.Resources> <CheckBox DataContext="{StaticResource viewModel}" IsChecked="{Binding IsViewModelEnabled, Mode=TwoWay}"> <TextBlock> <i:Interaction.Triggers> <ei:DataTrigger Binding="{Binding IsViewModelEnabled}" Value="true"> <ei:ChangePropertyAction PropertyName="Text" Value="Changed!!"/> </ei:DataTrigger> <ei:DataTrigger Binding="{Binding IsViewModelEnabled}" Value="false"> <ei:ChangePropertyAction PropertyName="Text" Value=""/> </ei:DataTrigger> </i:Interaction.Triggers> </TextBlock> </CheckBox> </UserControl>