<Window x:Class="EffectsWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<ListView ItemsSource="{Binding EffectsViewModel.Effects}">
<ListView.View>
<GridView>
<GridViewColumn Width="200" Header="Effects">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center"
Text="{Binding Name}"
TextAlignment="Center" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Window>
Effect
सिर्फ एक प्रकार का नाम संपत्ति है जो एक स्ट्रिंग देता है, लेकिन टेक्स्ट अभी भी अपने सेल के अंदर केंद्रित नहीं है।ग्रिड व्यू कॉलम के अंदर टेक्स्टब्लॉक कैसे केंद्रित करें? (नमूना xaml शामिल)
इसे ठीक करने के तरीके पर कोई विचार?
धन्यवाद लेकिन वह कोड सभी ListViewItems को केंद्रित करता है, है ना? मैं बस कुछ स्तंभों को केंद्र बनाना चाहता हूं, और दूसरों के रूप में होना चाहिए (बाएं से गठबंधन)। –
@ जोन वेंग: यह कॉलम को केन्द्रित करेगा जहां आपने 'क्षैतिज एलाइनमेंट = "केंद्र" सेट किया है, अन्यथा इसे गठबंधन किया जाएगा (या जो कुछ भी आप निर्दिष्ट करते हैं) –
मेलेक, जो काम करता है। धन्यवाद, लेकिन एक छोटी सी समस्या है। असल में मैं इस वैकल्पिक रंगों का उपयोग करता हूं: http://blogs.msdn.com/b/vinsibal/archive/2008/05/28/wpf-3-5-sp1-feature-alternating-rows.aspx पहला xaml उदाहरण है, जो शैली भी सेट करता है, इसलिए वे एक साथ काम करने के लिए काम नहीं लगते हैं। क्या इन्हें गठबंधन करना संभव है? –