我开发windows phone 8应用程序。这是我的XAML
项目模板
<phone:PhoneApplicationPage.Resources>
<data:AppCollection x:Key="AppCollection"/>
<DataTemplate x:Key="AppItemTemplate">
<StackPanel Margin="0,-14,0,24" Tap="OnItemContentTap" >
<TextBlock Text="{Binding Name}"
Margin="0,0,0,-4"
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
<TextBlock Text="{Binding Body}"
Margin="0,0,0,-4"
Foreground="{StaticResource PhoneSubtleBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"
FontFamily="{StaticResource PhoneFontFamilyLight}"/>
<TextBlock Text="{Binding Description}"
Foreground="{StaticResource PhoneSubtleBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
这里是LongListMultiSelector
<toolkit:LongListMultiSelector x:Name="AppList"
Margin="0,14,-12,0"
ItemsSource="{StaticResource AppCollection}"
LayoutMode="List"
SelectionChanged="OnAppListSelectionChanged"
IsSelectionEnabledChanged="OnAppListIsSelectionEnabledChanged"
ItemTemplate="{StaticResource AppItemTemplate}"
/>
</phone:PivotItem>
这是app的截图:
所以我需要使用相同的LongListMultiSelector但使用ToggleSwitchers。就像这张照片:
当select处于活动状态时,是否可以将切换开关添加到长列表并隐藏开关?
答案 0 :(得分:0)
ToggleSwitch是一个可以在Windows Phone Toolkit库中找到的控件。
您可以通过NuGet轻松地将该库添加到您的项目中:右键单击您的项目 - &gt; “管理NuGet包”然后搜索“WPtoolkit”。
尝试在数据模板中添加切换开关。
<ToggleSwitch Header="Toggle Switch Example"
OffContent="Do work" OnContent="Working"
Toggled="ToggleSwitch_Toggled"/>
了解详情here
答案 1 :(得分:0)
在dataTemplate中创建包含两列的Grid。所以LongList Multi Selector有这样的ItemTemplate:
<DataTemplate x:Key="ReminderItemTemplate">
<Grid Name="ListGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<StackPanel Tap="OnItemContentTap" Grid.Column="0" >
<TextBlock Text="{Binding Name}"
Margin="0,0,0,-4"
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
<TextBlock Text="{Binding Adress}"
Margin="0,0,0,-4"
Foreground="{StaticResource PhoneSubtleBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"
FontFamily="{StaticResource PhoneFontFamilyLight}"/>
<TextBlock Text="{Binding Description}"
Foreground="{StaticResource PhoneSubtleBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"/>
</StackPanel>
<!--And here I insert toggleswitch-->
<StackPanel Tap="OnItemContentTap" Grid.Column="1" >
<toolkit:ToggleSwitch Margin="0,20,20,0" >
</toolkit:ToggleSwitch>
</StackPanel>
</Grid>
</DataTemplate>