1
我有一个DropDown列表和2个单选按钮。我需要更改每个按钮更改DD列表数据源。WinRT:以编程方式设置DropDown列表来源
XAML:
<Page
x:Class="myapp.MyTags"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ReqWriter8"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="Page_Loaded">
<Page.Resources>
<CollectionViewSource x:Name="MyAxureHTML" Source="{Binding }"/>
<CollectionViewSource x:Name="MyControlTypeIDs" Source="{Binding }"/>
</Page.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="480*"/>
<ColumnDefinition Width="203*"/>
</Grid.ColumnDefinitions>
<!-- Back button and page title -->
<Grid x:Name="titlePanel" Background="Gray" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--Command="{Binding NavigationHelper.GoBackCommand, ElementName=MainPage}"-->
<Button x:Name="backButton" Margin="39,59,0,0"
Style="{StaticResource BackButtonStyle}"
VerticalAlignment="Top"
AutomationProperties.Name="Back"
AutomationProperties.AutomationId="BackButton"
AutomationProperties.ItemType="Navigation Button" Width="71"/>
<TextBlock x:Name="pageTitle" Text="Setup Requirement Statements" Style="{StaticResource HeaderTextStyle}" Grid.Column="1"
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Top" Margin="2,63,-2,0"/>
</Grid>
<RadioButton x:Name="btA" Content="Axure HTML" HorizontalAlignment="Left" Margin="353,184,0,0" VerticalAlignment="Top"/>
<RadioButton x:Name="btB" Content="Balsamiq XML" HorizontalAlignment="Left" Margin="542,184,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="cbWidget" HorizontalAlignment="Left" Margin="356,297,0,0" VerticalAlignment="Top" Width="307" MaxDropDownHeight="15"/>
</Grid>
</Page>
代码:
Private Sub Init()
Dim dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, App.DB)
Using db = New SQLiteConnection(dbpath)
tblAxureHTML = From T In db.Table(Of AxureHTML)()
Where T.ClassName IsNot Nothing
Select T
tblControlTypeIDs = From T In db.Table(Of ControlTypeIDs)()
Where T.Name IsNot Nothing
Select T
MyAxureHTML.Source = tblAxureHTML
MyControlTypeIDs.Source = tblControlTypeIDs
db.Dispose()
db.Close()
End Using
cbWidget.ItemsSource = MyAxureHTML
End Sub
DB:SQLite的
首先,我不知道我怎么设置下拉listt的来源。其次,需要在单选按钮选择上进行更改。
任何想法?
好的,我自己找到了。现在问题是不同的。我的DropDown列表显示对象字段的对象但不是对象的文本值。所以在CBox中,我有像Object.Field而不是字段值的txt!我需要在表单应用中设置名为DisplayText的smth。 – Jalle 2014-09-06 20:31:56
@Jalle所以你需要的是'DisplayMemberPath'。 – Pragmateek 2014-09-06 21:12:34