Bir Windows 8 Metro uygulaması yazıyorum. Üç Grup ile bir GridView çizmeye çalışıyorum. Bu gruplardan birinin eşyalarını diğerlerinden farklı olarak düzenleyebilmesini istiyorum. WPF'de daha önce Selector kullandım, bu yüzden iyi bir yol olacağını düşündüm. Bu yüzden GroupStyleSelector denedim ve bu example on MSDN bulundu:Metro GridView'da Grupları nasıl farklı Layouts kullanabilirim?
CS:
public class ListGroupStyleSelector : GroupStyleSelector
{
protected override GroupStyle SelectGroupStyleCore(object group, uint level)
{
return (GroupStyle)App.Current.Resources["listViewGroupStyle"];
}
}
yüzden bana uygun olacağını birşeyden üzerinde genişletilmiş/değişmiş
public class ExampleListGroupStyleSelector : GroupStyleSelector
{
public ExampleListGroupStyleSelector()
{
OneBigItemGroupStyle = null;
NormalGroupStyle = null;
}
public GroupStyle OneBigItemGroupStyle { get; set; }
public GroupStyle NormalGroupStyle { get; set; }
protected override GroupStyle SelectGroupStyleCore(object group, uint level)
{
// a method that tries to grab an enum off the bound data object
var exampleListType= GetExampleListType(group);
if (exampleListType== ExampleListType.A)
{
return OneBigItemGroupStyle;
}
if (exampleListType== ExampleListType.B|| exampleListType== ExampleListType.B)
{
return NormalGroupStyle;
}
throw new ArgumentException("Unexpected group type");
}
}
XAML:
<Page.Resources>
<ExampleListGroupStyleSelector
x:Key="ExampleListGroupStyleSelector"
OneBigItemGroupStyle="{StaticResource OneBigGroupStyle}"
NormalGroupStyle="{StaticResource NormalGroupStyle}" />
</Page.Resources>
<GridView
ItemsSource="{Binding Source={StaticResource exampleListsViewSource}}"
GroupStyleSelector="{StaticResource ExampleListGroupStyleSelector}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel
Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
Ancak seçicide verdiğim grup boş veya bir DependencyObject tha Hiçbir veriyi alamıyorum. Herhangi bir bilgi verilmezse GroupStyle'ı nasıl değiştireceğime dair akıllıca bir karar vermem gerekiyor. Bir mülkü ekli bir mülkten veya bu satırlardaki bir şeyden geçirebileceğim bir yol var mı?