मैं उनकी नारंगी पृष्ठभूमि के साथ Listbox की पूरी चौड़ाई का विस्तार करने के लिए ListItems रखना चाहता हूं।
वर्तमान में वे केवल FirstName + LastName जैसे ही विस्तृत हैं।
मैंने हर वह तत्व निर्धारित किया है जो मैं कर सकता हूँ: HoroscopeAlignment = "Stretch"।
मैं चाहता हूं कि सूची बॉक्स की पृष्ठभूमि का विस्तार हो, क्योंकि उपयोगकर्ता सूची बॉक्स को खींचता है, इसलिए मैं पूर्ण मूल्यों में नहीं डालना चाहता।
मुझे क्या करना होगा ताकि सूची बॉक्स की पृष्ठभूमि का रंग सूची बॉक्स की चौड़ाई को भर दे?
<Window x:Class="TestListBoxSelectedItemStyle.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestListBoxSelectedItemStyle"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<local:CustomerViewModel x:Key="TheDataProvider"/>
<DataTemplate x:Key="CustomerItemTemplate">
<Border CornerRadius="5" Background="Orange" HorizontalAlignment="Stretch" Padding="5" Margin="3">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Width="Auto">
<TextBlock HorizontalAlignment="Stretch">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="FirstName"/>
<Binding Path="LastName"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox ItemsSource="{Binding Path=GetAllCustomers, Source={StaticResource TheDataProvider}}"
ItemTemplate="{StaticResource CustomerItemTemplate}"/>
</Grid>
</Window>