なんかエラー出てはまったので
こんなViewModelがあるとして
public class MainVM : BindableBase
{
private string _Title;
public string Titile
{
get { return _Title; }
set { SetProperty(ref _Title, value); }
}
private bool _IsVisible;
public bool IsVisible
{
get { return _IsVisible; }
set { SetProperty(ref _IsVisible, value); }
}
}
こんなXamlだとする。
<Window x:Class="WpfApplication1.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:WpfApplication1"
mc:Ignorable="d"
Height="350" Width="525"
Title="{Binding Title}"
Visibility="{Binding Path=IsVisible,Converter={StaticResource bvConv}}">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="bvConv" />
</Window.Resources>
<Grid>
</Grid>
</Window>
ぎゃ~~( ;∀;)
<Window x:Class="WpfApplication1.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:WpfApplication1"
mc:Ignorable="d"
Height="350" Width="525"
Title="{Binding Title}">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="bvConv" />
</Window.Resources>
<Window.Style>
<Style TargetType="{x:Type Window}">
<Setter Property="Visibility" Value="{Binding Path=IsVisible,Converter={StaticResource bvConv}}" />
</Style>
</Window.Style>
<Grid>
</Grid>
</Window>
でオッケー(^^)/