无法将标签内容绑定到属性以及在标签控件中填充的图标

问题描述 投票:0回答:1

我希望在标签内显示文本和图像。如何实现?

<toolkit:LabelledButton x:Name="Test"
                                                        AutomationProperties.AutomationId="TestBtn"                                                                  
                                                        Margin="0,1,0,0" Height="56"
                                >
            <toolkit:LabelledButton.Content>
                <Rectangle Fill="{DynamicResource Icon_Test}" Margin="0,2,0,-5"/>
                <!-- Content="{Binding TestParam}" **How do I set a text here and bind it to a property.** --> 
            </toolkit:LabelledButton.Content>   

        </toolkit:LabelledButton>
c# wpf xaml
1个回答
0
投票

u在label的content属性中应具有面板控件,以容纳多个控件。

        <toolkit:LabelledButton.Content>
            <Grid>
                  <Rectangle Fill="{DynamicResource Icon_Test}" Margin="0,2,0,-5"/>
                  <ContentPresenter Content="{Binding Content}"/>
            </Grid>
        </toolkit:LabelledButton.Content>  

U可以使用任何面板,在此示例中使用网格。

© www.soinside.com 2019 - 2024. All rights reserved.