1
有沒有辦法均勻佈局單選按鈕,包括單選按鈕文本?我已經嘗試了與方向=水平,DockPanel和UniformGrid的StackPanel,但我沒有達到我要去的確切外觀,這是控件之間的空白量,而不必包裝或截斷文本。Radiobutton甚至水平對齊
<GroupBox Name="grpLegend" Header="{x:Static res:Strings.ChartOptionsDisplayControlView_GroupBox_Legend}">
<ItemsControl
ItemsSource="{Binding IsAsync=True, Path=AvailablePitchbookLegendPosition}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton
Content="{Binding IsAsync=True, Path=DisplayName}"
IsChecked="{Binding IsAsync=True, Path=IsSelected}"
GroupName="LegendPosition"
Margin="2,3.5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
感謝。這絕對適用於靜態項目。我想知道這將如何與動態收集一起工作,因此可能會有不同數量的單選按鈕。 – dior001 2012-03-18 16:24:32
已更新的答案。查看Grid.IsSharedSizeScope以獲取更多示例。 – Phil 2012-03-18 16:28:57
謝謝你。我知道你的答案有效,但我還沒有能夠成功地將它應用到我的ItemsControl。我很困惑你如何將收集數據綁定到包含3個單選按鈕的模板,而不是一個。如果我這樣做,我只需要9個單選按鈕而不是3個。這只是我缺乏XAML知識。 – dior001 2012-03-18 17:46:11