Silverlight 如何在listbox控件中对齐最左侧的按钮?

Silverlight 如何在listbox控件中对齐最左侧的按钮?,silverlight,button,windows-phone-7,listbox,alignment,Silverlight,Button,Windows Phone 7,Listbox,Alignment,我正在开发WindowsPhone7应用程序。我对silverlight是新手。我正在动态创建按钮控件,并将这些按钮控件绑定到listbox <ListBox x:Name="lstButtons" Margin="393,-28,-12,28" Background="Orange"> <ListBox.ItemTemplate> <DataTemplate>

我正在开发WindowsPhone7应用程序。我对silverlight是新手。我正在动态创建按钮控件,并将这些按钮控件绑定到listbox

<ListBox x:Name="lstButtons" Margin="393,-28,-12,28" Background="Orange">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="{Binding ElementName}" Width="100" HorizontalAlignment="Right"></Button>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
 </ListBox>


现在我想在最左边显示button控件意味着我想在listbox的左边框附近显示button控件。我想显示向左对齐的按钮控件。使用我上面的代码,按钮控件出现在列表框的中心?我应该如何将其与左侧对齐?你能提供我任何代码或链接,通过它我可以解决上述问题吗?如果我做错了什么,请指导我

请查看中的样本XAML。您需要使用要在父元素中对齐的元素的HorizontalAlignment属性,也许可以通过设置元素的边距属性来微调对齐

这可能没有多大帮助,但我发现将expression blend用于布局/ui之类的事情是最简单的方法。您必须钻取列表模板,然后才能进行调整。

在这种情况下,您需要动态调整按钮。在下面的代码中,按钮在listbox控件的左侧对齐。它与listbox控件的左边框对齐

 Button AlphabetButton = new Button();                
                AlphabetButton.Margin = new Thickness(-10,-27,0,0);
                AlphabetButton.Width = 80;
                AlphabetButton.Height = 80;