我正在开发一个应用程序,我的Android手机连接到USB配件.但是,当连接附件时,是否有任何简单的方法来调试应用程序?
我们可以使用micro usb集线器或类似设备吗?
我试图将listview项绑定到结构的成员,但我无法让它工作.
结构很简单:
public struct DeviceTypeInfo
{
public String deviceName;
public int deviceReferenceID;
};
Run Code Online (Sandbox Code Playgroud)
在我的视图模型中,我保存了这些结构的列表,我想让"deviceName"显示在列表框中.
public class DevicesListViewModel
{
public DevicesListViewModel( )
{
}
public void setListOfAvailableDevices(List<DeviceTypeInfo> devicesList)
{
m_availableDevices = devicesList;
}
public List<DeviceTypeInfo> Devices
{
get { return m_availableDevices; }
}
private List<DeviceTypeInfo> m_availableDevices;
}
Run Code Online (Sandbox Code Playgroud)
我尝试过以下但是我无法使绑定工作,我需要使用relativesource吗?
<ListBox Name="DevicesListView" Grid.Column="0" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10" MinHeight="250" MinWidth="150" ItemsSource="{Binding Devices}" Width="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding DeviceTypeInfo.deviceName}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud) 我创建了一个简单的依赖属性,我想将其附加到 TreeViewitem,我对其他控件(例如按钮)做了类似的事情,但无法弄清楚如何在树视图中使用 TreeViewItem 而不丢失我定义的样式。通过下面的代码,我得到“用于类型‘ErrorTreeViewItem’的样式不能应用于类型‘TreeViewItem’。”
public class ErrorTreeViewItem : TreeViewItem
{
static ErrorTreeViewItem()
{
}
public bool ErrorState
{
get { return (bool)GetValue(ErrorStateProperty); }
set { base.SetValue(ErrorStateProperty, value); }
}
public static readonly DependencyProperty ErrorStateProperty =
DependencyProperty.Register("ErrorState", typeof(bool), typeof(ErrorTreeViewItem), new UIPropertyMetadata(false));
}
Run Code Online (Sandbox Code Playgroud)
我的树视图的样式如下所示:
<Style TargetType="me:ErrorTreeViewItem">
<Style.Resources>
...
</Style.Resources>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
...
</Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)
我使用它的方式如下:
<TreeView Name="ApplicationTree" ItemsSource="{Binding Applications}" HorizontalContentAlignment="Stretch" Background="#E8E8E8" >
<TreeView.ItemContainerStyle>
<Style TargetType="me:ErrorTreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" …Run Code Online (Sandbox Code Playgroud) 对于我正在处理的应用程序,我想创建一个自定义控件,上面有几个按钮,如果有太多按钮我需要它来滚动.但是,我不想使用标准滚动条而只是想在控件的两端有两个按钮向上滚动而另一个向下滚动.实现这一目标的最佳方法是什么?
是否可以更改滚动条的样式,使它们只是按钮而不是完整的水平GUI?
我有一个简单的对话框列表,其中包含一些复选框,我想要一个Ok按钮,除非用户更改了设置,否则该按钮将被禁用.在我看来,我有一个OkEnabled属性,我正在绑定按钮的isEnabled属性,如果一个复选框更改其值,它将OkEnabled设置为true,但由于某种原因,这不启用按钮.
public bool OkEnabled
{
get
{
return m_okEnabled;
}
set
{
m_okEnabled = value;
OnPropertyChanged("OkEnabled");
}
}
Run Code Online (Sandbox Code Playgroud)
<Button Content="OK" Style="{StaticResource MyButton}" Height="23"
HorizontalAlignment="Left" Margin="20" Name="m_okbutton"
VerticalAlignment="Top" Width="75"
Click="okClick" IsEnabled="{Binding Path=OkEnabled}"/>
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当OkEnabled属性改变状态时,Ok按钮不会改变状态.如果我将IsEnabled属性绑定到其中一个复选框,我可以看到按钮更改状态,因为复选框更改.
wpf ×4
data-binding ×2
android ×1
button ×1
isenabled ×1
listview ×1
scrollviewer ×1
treeview ×1
treeviewitem ×1
usb ×1