0

2つの質問があります。

1日 Windows Embedded Compact 7にSilverlightを使用していますが、バインディングに問題があります。

私はこのようなテンプレートを持っています

<Style TargetType="RadioButton" x:Key="VoltageTab">
    <Setter Property="Width" Value="95"/>
    <Setter Property="Height" Value="61"/>
    <Setter Property="Margin" Value="193,0,192,3"/>
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Setter Property="VerticalAlignment" Value="Bottom"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <Grid Background="#00000000">
                            <Image x:Name="UnCheckedimg" Source="12.png"/>
                            <Image x:Name="Checkedimg" Visibility="Collapsed" Source="11.png"/>
                            <TextBlock x:Name="ModeName" FontSize="20" FontFamily="Alternate_Gothic_No.ttf#Alternate-Gothic-No3" Text="VOLTAGE" Foreground="#D25A32" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,4,0,0" />
                            <TextBlock  x:Name="ModeValue" FontSize="20" FontFamily="Alternate_Gothic_No.ttf#Alternate-Gothic-No3" Text="{TemplateBinding Content}" HorizontalAlignment="Center"  VerticalAlignment="Bottom" Margin="0,0,0,2"/>
                            <TextBlock x:Name="ModeNameChecked" Visibility="Collapsed" FontSize="34" FontFamily="Alternate_Gothic_No.ttf#Alternate-Gothic-No3" Text="VOLTAGE" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

TemplateBindingを使用してModeValueテキストブロックをバインドしていますが、ModeNameをバインドするには別のバインドが必要です。誰かが私にこれを行う方法を教えてもらえますか?

  1. 私は別のスタイルを持っています

編集:編集者が私にそれをここに投稿することを許可しなかったので、2番目のスタイルは以下に投稿されます

コンテンツにテキストを入れるだけなら問題ありませんが、オブジェクトを実行して、ボタン内のテキストをフォーマットできるようにします。

これは可能ですか?そうでない場合、これを達成する他の方法はありますか?

私はSilverlightForWindows組み込みを使用していることに注意してください。

よろしく、ルカ


 <Style x:Key="FunctionSelectButton" TargetType="RadioButton">
    <Setter Property="Width" Value="154"/>
    <Setter Property="Height" Value="61"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <Grid Background="#00000000">
                        <Image x:Name="NormalImg" Source="mode_unpressed.png" Stretch="None"/>
                        <TextBlock x:Name="NormalText" Foreground="#D25A32" FontSize="26" FontFamily="Alternate_Gothic_No.ttf#Alternate-Gothic-No3" HorizontalAlignment="Center" Text="{TemplateBinding Content}" VerticalAlignment="Center" Margin="0,0,0,0"></TextBlock>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

表現しやすい画像->画像

4

1 に答える 1

1

最初の質問に答えるには、こちらをご覧ください

あなたの2番目の質問ですが、質問が何であるかを完全に理解しているかどうかはわかりませんが、あなたが探しているのは、代わりに contenttemplate を使用して ContentPresenter として設定することだと思います。

<Style x:Key="FunctionSelectButton" TargetType="RadioButton">
    <Setter Property="Width" Value="154"/>
    <Setter Property="Height" Value="61"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <Grid>
                        <Image x:Name="NormalImg" Source="mode_unpressed.png" Stretch="None"/>
                        <ContentPresenter x:Name="contentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}" />

<!--
<TextBlock x:Name="NormalText" Foreground="#D25A32" FontSize="26" FontFamily="Alternate_Gothic_No.ttf#Alternate-Gothic-No3" HorizontalAlignment="Center" Text="{TemplateBinding Content}" VerticalAlignment="Center" Margin="0,0,0,0"></TextBlock>
-->
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

<Button Content="{Binding RPE-2WIRE}" Style="{StaticResource FunctionSelectButton}" FontFamily="Alternate_Gothic_No.ttf#Alternate-Gothic-No3" Foreground="#D25A32" FontSize="26" />

少なくともそれはあなたが言っていることだと思います:)

于 2012-08-23T19:52:27.330 に答える