Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Last active August 29, 2015 14:26
Show Gist options
  • Save yuka1984/b77bda110dff2404e6cb to your computer and use it in GitHub Desktop.
Save yuka1984/b77bda110dff2404e6cb to your computer and use it in GitHub Desktop.
WPFでWindowとかUserControlエレメントでStaticResourceを呼ぶとエラーになった ref: http://qiita.com/yu_ka1984/items/e77c4c03375435bf613c
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); }
}
}
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment