I am developing window phone 7 application. I am new to the silverlight. I am dynamically creating the button control and binding these all button controls to the 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>
Now I want to display the button control at the leftmost side means I want to display the button control near to the left border of the listbox. I want to display the button control which is aligned to the left. With my above code the the button control appears in the center in the listbox ? How should I align it to the left ? Can you please provide me any code or link through which I can resolve the above issue ? If I am doing anything wrong then please guide me.
For this scenario you need to align the button dynamically. In the following code the button is aligned at the left side in the listbox control. It is aligned close to the left border of the listbox control.