質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

XAML

XAML(Extensible Application Markup Language)はWPF、Silverlight、Windows PhoneそしてWindows Store appsでユーザーインターフェースを定義するために使われるXML言語です。

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

Q&A

解決済

1回答

8589閲覧

C#WPFにて背景が黒くなる

退会済みユーザー

退会済みユーザー

総合スコア0

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

XAML

XAML(Extensible Application Markup Language)はWPF、Silverlight、Windows PhoneそしてWindows Store appsでユーザーインターフェースを定義するために使われるXML言語です。

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

0グッド

0クリップ

投稿2016/04/30 13:25

###前提・実現したいこと
現在、デスクトップマスコットをC#とWPFを使用して制作しているのですが、BackgroundプロパティをTransparentに設定しているのになぜか背景が黒くなってしまいます。一体どのように修正すれば背景が透明になるでしょうか?

###発生している問題・エラーメッセージ

Visual Studio 2015 Community上では透明になっている(?)

イメージ説明

だが、何故か実行すると背景が黒くなる。

イメージ説明

###該当のソースコード
Win_Main.xaml

XAML

1<Window x:Class="Windowsさん.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:local="clr-namespace:Windowsさん" 7 mc:Ignorable="d" 8 Height="300" Width="300" 9 Background="Transparent" WindowStyle="None" > 10 <Grid> 11 12 <local:UseCtrl_Normal Visibility="Visible" /> 13 <local:UseCtrl_Nami Visibility="Hidden" /> 14 <local:UseCtrl_Oko Visibility="Hidden" /> 15 <local:UseCtrl_Tere Visibility="Hidden" /> 16 <local:UseCtrl_tumu Visibility="Hidden" /> 17 18 </Grid> 19</Window> 20

UseCtrl_Normal.xaml(他にもあるが中身は殆ど同じなので…)

XAML

1<UserControl x:Class="Windowsさん.UseCtrl_Normal" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 5 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 6 xmlns:local="clr-namespace:Windowsさん" 7 mc:Ignorable="d" 8 d:DesignHeight="300" d:DesignWidth="300" 9 Background="Transparent"> 10 <Viewbox> 11 <Grid> 12 <Path Data="M101,8.1666667 L124.5,44.333 170,44.833338 197.83333,8.8330125 232.00044,110.66821 199.83367,130.50151 273.25058,133.25155 271.00057,153.50186 184.75028,156.75191 187.75029,195.00248 221.33374,292.33729 189.33363,292.67095 164.33355,219.66952 134.66678,219.00285 110.33336,292.33729 77.333254,292.33729 111.33364,195.00249 115.00031,156.66857 28.333503,153.66853 26.000503,134.00157 97.333859,131.6682 61.750515,111.50123 z" Fill="#FFF4F4F5" Margin="26,8.167,26.75,7.333" Stretch="Fill"/> 13 <Ellipse Fill="Black" HorizontalAlignment="Left" Height="20" Margin="107.166,66.834,0,0" VerticalAlignment="Top" Width="20"/> 14 <Ellipse Fill="Black" HorizontalAlignment="Right" Height="20" Margin="0,66.834,108.167,0" VerticalAlignment="Top" Width="20"/> 15 <Path Data="M138.25,112.5 L141.125,114.875 147.125,107.125 156.75,118.75 160.25,116.25 147.5,100.5 138.125,112" Fill="Black" Height="18.25" Margin="138.125,100.5,139.75,0" Stretch="Fill" VerticalAlignment="Top"/> 16 <Path Data="M145.875,182.125 L143.875,183.625 148.5,188.375 144.125,192.75 145.625,195.5 150.375,190.875 154.875,195.25 156.625,193 152.25,188.75 157.125,184.125 155,182 150.5,186.25 z" Fill="Black" Height="13.5" Margin="143.875,0,142.875,104.5" Stretch="Fill" VerticalAlignment="Bottom"/> 17 </Grid> 18 </Viewbox> 19</UserControl> 20

###試したこと
UseCtrl_NormalのbackgroundプロパティをTransparentに変更したが効果なし。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

Windowの外観でAllowsTransparencyにチェックを入れると(AllowsTransparency="True")背景が透明なウィンドウにできます。

投稿2016/04/30 13:42

編集2016/04/30 13:43
catsforepaw

総合スコア5938

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2016/05/01 02:11

ありがとうございます。無事透明になりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問