我正在尝试编写一个简单的WPF学习项目,该项目在可调整大小的主窗口中创建一组按钮.还有就是要成为一个Button每一个集合中的条目,该集合的内容可能会在运行时有所不同.我希望按钮能够填满整个窗口(例如1个按钮@ 100%宽度,2个按钮@ 50%宽度,3个按钮@ 33%宽度等等都在100%高度).我到目前为止所编写的简化版本是:
<ItemsControl x:Name="itemscontrolButtons" ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Tag="{Binding}">
<TextBlock Text="{Binding}" />
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
...
List<string> listButtonTexts = new List<string>() { "Button1", "Button2" };
...
itemscontrolButtons.DataContext = listButtonTexts;
Run Code Online (Sandbox Code Playgroud)
这导致:

我一直无法使按钮拉伸以适应宽度,我尝试使用Grid而不是StackPanel没有结果.
然后,作为一个可选的改进,我将很感激如何调整它的建议,如果有这么多的按钮,他们不能正确地适合在一条线上或比一个阈值窄,它将包裹到一个新的线(从而减半按钮高度,如果从1到2行).
我想强调一下,我想知道如何以WPF的方式做到这一点.我意识到我可以使用窗口调整大小的消息并显式调整控件的大小,这就是我用MFC或WinForms完成它的方式,但从我读过的内容并不是如何用WPF完成的.
我如何确定特定IP地址源自使用c#的国家/地区.我需要使用它来检查连接是否来自特定国家/地区.
我有一些代码尝试模拟调用者的Windows安全设置,然后连接到另一台机器上的另一个WCF服务
WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;
using (callerWindowsIdentity.Impersonate())
{
NetTcpBinding binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
EndpointAddress endpoint = new EndpointAddress(new Uri("net.tcp://serverName:9990/TestService1"));
ChannelFactory<WCFTest.ConsoleHost.IService1> channel = new ChannelFactory<WCFTest.ConsoleHost.IService1>(binding, endpoint);
WCFTest.ConsoleHost.IService1 service = channel.CreateChannel();
return service.PrintMessage(msg);
}
Run Code Online (Sandbox Code Playgroud)
但是我收到错误:"调用者没有通过服务验证"System.ServiceModel ....由于身份验证失败,无法满足安全令牌的请求...
我试图模仿的凭据是服务所在框的valide windows凭证.
有什么想法吗?
有没有办法使用Objective-C获得iPhone的载体和/或当前的信号强度?我知道如何确定数据连接是否存在,以及该连接是否是wi-fi与蜂窝连接.我也知道您可以通过转到手机应用程序手动将iPhone置于"现场测试"模式,并拨打#3001*12345*#并点击发送.
我已经设置了一个指向Oracle DB的链接服务器.我想在包XYZ传递参数K中调用函数ABC.这样做的语法是什么?
我正在通过慢速网络连接运行X. 如何判断窗口何时可见?我需要等待,以便我可以在可见窗口上执行另一个操作.
xterm -T foo &
# how to flush the display, or wait until the window is visible?
# polling the visibility would be acceptable as well
xmovewindow foo 10 20
Run Code Online (Sandbox Code Playgroud)
更新:感谢Jim Lewis,这里有一个快速的shell函数可以解决问题.
function xwait() {
while ! xwininfo -name $1|grep 'Map State: IsViewable';do sleep 1;done
}
xterm -T foo &
xwait foo
xmovewindow foo 10 20
Run Code Online (Sandbox Code Playgroud) 我有这个问题:
SELECT g.title, g.asin, g.platform_id, r.rank
FROM games g
INNER JOIN ranks r ON ( g.id = r.game_id )
ORDER BY r.rank DESC
LIMIT 5`
Run Code Online (Sandbox Code Playgroud)
现在,这是我的JOIN使用,Zend_Db_Select但它给了我数组错误
$query = $this->select();
$query->from(array('g' => 'games'), array());
$query->join(array('r' => 'ranks'), 'g.id = r.game_id', array('g.title', 'g.asin', 'g.platform_id', 'r.rank'));
$query->order('r.rank DESC');
$query->limit($top);
$resultRows = $this->fetchAll($query);
return $resultRows;Run Code Online (Sandbox Code Playgroud)
谁知道我可能做错了什么?我希望显示"游戏"中的所有列以及排名表中的"排名"列.
我想在我的设置完成后启动我的应用程序.我尝试在自定义操作中启动cmd文件,但VS安装项目不想获取cmd文件,这是一个无效的自定义操作文件.
我知道我可以写一个安装程序类,但有一个简单的方法来做这个简单的操作吗?
我正在使用JBoss运行客户端/服务器应用程序.
如何连接到服务器JVM的MBeanServer?我想使用MemoryMX MBean来跟踪内存消耗.
我可以使用JNDI查找连接到JBoss MBeanServer,但java.lang.MemoryMX MBean未在JBoss MBeanServer中注册.
编辑:要求从客户端以编程方式访问内存使用情况.
这是一个小测试:
function inc(n:integer):integer;
begin
n := n+1;
result := n;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
start,i,n:integer;
begin
n := 0;
start := getTickCount;
for i := 0 to 10000000 do begin
inc(n);//calling inc function takes 73 ms
//n := n+1; writing it directly takes 16 ms
end;
showMessage(inttostr(getTickCount-start));
end;
Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
asp.net ×1
delphi ×1
geolocation ×1
installation ×1
iphone ×1
itemscontrol ×1
java ×1
jboss ×1
jmx ×1
join ×1
mbeans ×1
optimization ×1
oracle ×1
select ×1
signals ×1
sql ×1
sql-server ×1
visibility ×1
wcf ×1
wpf ×1
x11 ×1
xaml ×1
zend-db ×1