2016-05-08 15 views
0

イメージとテキストを含むWPFアプリケーションのカントメイクボタン。WPF - テキストと画像付きのボタン

<Window x:Class="WindowR.One" 
     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:WindowR" 
     mc:Ignorable="d" 
     Title="One" Height="300" Width="300"> 

    <Grid> 
     <StackPanel Orientation="Vertical"> 
      <TextBlock Text="Click Here" /> 
      <Image Source="D:\Skola\4. semester\TP\GIT folder\Visualko\Core\WindowR\Pictures\0.png" /> 
     </StackPanel> 
    </Grid> 

</Window> 

しかしからチュートリアルのimage..triedたくさん上記テキストイマイチはhere..butそれらのどれものTextBlock次の画像に適切に

+0

StackPanelはImageの横にTextBlockを配置しています。 'Grid'を使うようにしてください – ASh

+0

@RadoInkoは' Orientation'を垂直に設定しました – dkozl

+0

何かが恋しくなるのですか?画像とテキストはまだ互いに隣り合っていて、別のものとは重なっていない – RadoInko

答えて

0

StackPanel並べ動作しません:私のコードは次のようです。お試しください。Grid

<Button Width="120" Height="50" > 
    <Grid> 
     <Image Source="D:\Skola\4. semester\TP\GIT folder\Visualko\Core\WindowR\Pictures\0.png" /> 
     <TextBlock Text="Click Here" 
        VerticalAlignment="Center" 
        HorizontalAlignment="Center" /> 
    </Grid> 
</Button> 
+0

今のコードはうまくいくはずです。試してみると、画像がテキストの下に表示されます。 – ChrisF

+0

@ChrisF、多分。 OPからのフィードバックが必要です。私の理解では、「ボタンの上にテキストを置く」という要件があります。 – ASh

+0

指定された高さと幅を持つボタンの内側でさえ、スタックパネルを使って "うまくいく"べきである。私は私の(今削除された)回答を掲示した後に質問が変わったことは疑いがあります。 – ChrisF

関連する問題