我是一名iOS開發者,現在我接近.NET的Windows 8商店應用的開發現在。 嗯,我有這樣的問題:我創建了一個分組的ListView使用XAML這樣的:XAML分組的ListView:更改行背景顏色
<ListView Margin="0,10,50,50"
x:Name="listView"
AutomationProperties.AutomationId="listView"
AutomationProperties.Name="Grouped Items"
Grid.Row="1"
Background="LightGray"
BorderBrush="#FF818181"
ItemsSource="{Binding Source={StaticResource groupedIndexViewSource}}"
ItemTemplate="{StaticResource StandardSubIndexNOIcon320x70ItemTemplate}"
BorderThickness="0,1,1,1"
SelectionMode="None"
IsSwipeEnabled="false"
IsItemClickEnabled="True"
ItemClick="itemClicked">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid x:Name="Prr"
Width="315"
Margin="-5,0,0,2"
Height="70"
Background="#FFB9B9B9">
<Button Width="315"
Height="70"
Margin="0"
Click="HeaderClicked"
BorderThickness="0"
BorderBrush="{x:Null}"
Foreground="{x:Null}"
Background="{x:Null}"
Padding="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="260" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Width="250"
Margin="10,0,0,0"
Text="{Binding Title}"
Style="{StaticResource BodyTextStyle}"
TextWrapping="NoWrap"
FontSize="20"
Foreground="#DE000000"
VerticalAlignment="Center"
TextAlignment="Left"
HorizontalAlignment="Left" />
</Grid>
</Button>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
現在,我想改變標題按鈕的背景顏色在HeaderTemplate中單擊了定義,因此,在我的c#代碼我已經定義了這個方法:
private void HeaderClicked(object sender, RoutedEventArgs e)
{
((Grid)((Button)e.OriginalSource).Parent).Background = new SolidColorBrush(Colors.DarkBlue);
}
問題是這條指令被忽略。
你能幫我解決這個問題嗎?
在此先感謝。
更新:
隨着DanM我剛剛發現,我其實對這個屬性問題的幫助: ((網格)((按鈕)e.OriginalSource).Parent)裝置技術領域predefinite型「微軟.CSharp.RuntimeBinder.Binder」沒有定義或導入
這是從意大利翻譯成英文(我的IDE是意大利人)。
當我在引用 - >添加引用 - >程序集 - >框架我只能看到一條消息,說我已經所有引用框架,並且我需要使用「對象查看器」來探索引用框架...
我不知道這意味着什麼......
您的帖子被標記爲與WPF,但你的問題建議你正在建設一個Windows Store應用程序,這將使用Windows Runtime和不是WPF。這是什麼?儘管它們都基於XAML,但還是有一些相當大的差異。 –
Windows商店應用程序。對不起 –