我试图绑定一个字典的键在一个表中网格的一个排,和字典的值绑定到网格的另一行.key的类型是Book,类是thati写的,值的类型是int.我想写一下类的元素和网格中的整数值.你能帮帮我吗?在确定itemsSource和要绑定的数据类型时我很困惑.谢谢你的帮助
编辑:我忘了说我正在使用c# - wpf.=)
我发送的词典作为的ItemsSource,以及i所指定的字典为类型中的ObjectDataProvider标签,并试图通过该代码来发送值(INT):
< TextBlock Text="{Binding Value, Mode=OneWay}" Grid.Row="1" Width="65" >
Run Code Online (Sandbox Code Playgroud)
并且selecteditem显示为[myNameSpace.Book,4]而不是4.
BookListBox.ItemsSource = LibManager.Books;
Run Code Online (Sandbox Code Playgroud)
这是我在Window.xaml.cs中写的,Books是BookList,其中BookList是一种字典<Book,int>.
和xaml文件:
< ListBox Height="571" HorizontalAlignment="Left" Margin="444,88,0,0"
Name="BookListBox" VerticalAlignment="Top" Width="383" >
< ListBox.Resources>
<ObjectDataProvider x:Key="BookData"
ObjectType="{x:Type local:BookList}"/>
</ListBox.Resources>
< ListBox.ItemTemplate>
< DataTemplate>
< Border BorderThickness="2" BorderBrush="Black" Margin="5"
CornerRadius="5" Width="350" >
< Grid DataContext="{StaticResource BookData}" >
< Grid.ColumnDefinitions>
< ColumnDefinition/>
</Grid.ColumnDefinitions>
< Grid.RowDefinitions>
< RowDefinition/>
< RowDefinition/>
< /Grid.RowDefinitions>
< Label Content="count: " />
< TextBlock Text="{Binding Value, Mode=OneWay}"
Grid.Row="1" Width="65"/>
< /Grid>
< …Run Code Online (Sandbox Code Playgroud) 用户输入任何字符串,程序会区分字符串是否符合条件的产品ID.
符合条件的产品ID是由两个大写字母和四个数字组成的字符串中的任何一个.(例如,"TV1523")
我该如何制作这个节目?
我有一个本地化的输入字段.我需要使用正则表达式添加验证,它必须只使用字母和数字.[a-z0-9]如果我只使用英语,我可以使用.
截至目前,我正在使用该方法Character.isLetterOrDigit(name.charAt(i))(是的,我正在迭代每个字符)来过滤掉各种语言中的字母表.
有没有更好的方法呢?任何正则表达式或其他可用的库?
例:
/(?:美孚){0}酒吧/
我在另一个答案中看到了类似的东西.起初我想"应该是什么",然后,"好的可能有意义,背后有一种负面的看法",所以Foo以前不允许bar,但这不起作用.
你可以在Regexr上看到这个:它只匹配,bar但它也与barin 匹配Foobar.
当我为行的开头添加锚点时:
/^(?:Foo){0}bar/
Run Code Online (Sandbox Code Playgroud)
它表现得像我期待的那样.它只是相匹配bar,而不是bar在Foobar.
但这与我只使用/bar/或使用的行为完全相同/^bar/.
量词{0}只是一种无用的副作用,还是真的有用的行为呢?
我需要能够点击imgviewa listview,这应该打开一个显示图像fullsize的弹出窗口.我已经设法实现了clicklistener,但是在创建弹出窗口时仍然没有成功,即使只是进行测试textview.
在我的mainActivity oncreate中运行
lstView.setAdapter(new CustomListViewAdapter(this, dataFromDBListe, 0, orientation));
Run Code Online (Sandbox Code Playgroud)
在我的CustomListVievAdapter中,我有clicklistener(此时可以显示吐司)我有以下内容getView():
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.custom_row, null);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.prev = (TextView) convertView.findViewById(R.id.prevNrDate);
holder.prevTitle = (TextView) convertView.findViewById (R.id.prevTitle);
holder.next = (TextView) convertView.findViewById(R.id.nextNrDate);
holder.nextTitle = (TextView) convertView.findViewById (R.id.nextTitle);
holder.picture = (ImageView) convertView.findViewById (R.id.showPic);
holder.prevFast = (TextView) convertView.findViewById(R.id.prev);
holder.nextFast = (TextView) convertView.findViewById(R.id.next);
holder.linearLayout = …Run Code Online (Sandbox Code Playgroud) 您好Perl社区SO.我使用Perl已经有几年了,但是因为我遵循了这个,所以我认识到Perl还不够.
在过去的4年里,我写了一篇非常大的剧本,试图用OO风格来做这件事.我知道Perl <6并不是真的OO.
所以我不喜欢的一点是我没有数据封装,这意味着没有对包("类")真正私有的变量(或者我可能不知道如何去做).
我有这样的东西(只是我脚本的一小部分)
package TAG;
sub new () {
my $classname = shift;
my $self = {};
bless( $self, $classname );
$self->initialize();
return $self;
}
sub initialize() {
my $self = shift;
# Only an example, I have a long list of items in this "class"
$self->{ID} = "NA";
}
sub setID() {
...
}
sub getID() {
...
}
Run Code Online (Sandbox Code Playgroud)
在我的主脚本中,我正以这种方式使用它:
my $CurrentItem;
$CurrentItem = new TAG();
$CurrentItem->getID()
Run Code Online (Sandbox Code Playgroud)
但
$CurrentItem->{ID} = "Something";
Run Code Online (Sandbox Code Playgroud)
也在工作,但我更希望,这是不可能的.
有没有办法更好地封装我在"类"中使用的数据,以便我(或其他用户)被迫使用get和set方法?
我目前正在研究将2d地形图保存为一维数组的项目.地图中的每个块都由xy坐标索引.因此,为了将地图保存为一维数组,我使用行主要顺序方法(http://en.wikipedia.org/wiki/Row-major_order)将xy坐标转换为单个索引值(其中让我把块放到一个数组中).
现在,我的问题是如何将其转换回来?我有一个唯一的号码,我必须转换回xy坐标.任何帮助,将不胜感激.^^
如何使用Qt(C++)通过名称检查程序是否正在运行.
会QProcess::pid做这个工作吗?我不知道如何使用它.请建议.
我的推送通知正在运行.有用.我收到通知并使用
application:didReceiveRemoteNotification:
Run Code Online (Sandbox Code Playgroud)
获取传入的数据,然后将用户发送到必要的屏幕.
问题是,如果您正在使用应用程序并收到通知,它会跳转到目标屏幕而不会发出任何警报/声音/任何内容.
我可以发出警报application:didReceiveRemoteNotification:,但每次都会出现警报,而不仅仅是应用程序运行时.
关于如何处理这个的想法?
我正在尝试使用正则表达式来查找字符串中的三个或更多相同的字符.所以例如:'你好'不会匹配'ohhh'会.
我尝试过这样的事情:
re.compile('(?!.*(.)\1{3,})^[a-zA-Z]*$')
re.compile('(\w)\1{5,}')
Run Code Online (Sandbox Code Playgroud)
但似乎都不起作用.
regex ×4
java ×2
android ×1
binding ×1
block ×1
c# ×1
c++ ×1
coordinate ×1
dictionary ×1
indexing ×1
iphone ×1
listbox ×1
localization ×1
map ×1
perl ×1
popupwindow ×1
process ×1
python ×1
qprocess ×1
qt ×1
qt-creator ×1
unicode ×1
wpf ×1