我正在尝试创建一个具有2列的GridLayout,这些列将居中.
我的avtual设计是:
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
custom:rowCount="4"
custom:columnCount="2"
android:orientation="horizontal">
<TimeTableKeeper.Tile
android:layout_width="75dp"
android:layout_height="75dp"
android:gravity="top|left"
android:background="#00FF00"
custom:color="green"
custom:layout_row="0"
custom:layout_column="0" />
<TimeTableKeeper.Tile
android:layout_width="75dp"
android:gravity="top|left"
android:layout_height="75dp"
android:background="#00FF00"
custom:color="blue"
custom:layout_row="0"
custom:layout_column="1" />
</GridLayout>
Run Code Online (Sandbox Code Playgroud)
它看起来像:

我希望这个按钮位于中间,并且它们之间的距离非常合适.
可能吗?
- 编辑:
我也尝试将它放入LinearLayout,没有结果:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<GridLayout xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
custom:rowCount="4"
custom:columnCount="2"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center">
<TimeTableKeeper.Tile
android:layout_width="75dp"
android:layout_height="75dp"
android:background="#00FF00"
custom:color="green"
custom:layout_row="0"
custom:layout_column="0" />
<TimeTableKeeper.Tile
android:layout_width="75dp"
android:layout_height="75dp"
android:background="#00FF00"
custom:color="blue"
custom:layout_row="0"
custom:layout_column="1" />
</GridLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我在使用chrome调试用js bin编写的js代码时遇到问题.
每当我编辑/点击运行JS时,都会生成新的源文件,并且没有命中旧的断点.
你对这个问题有什么解决方案吗?
我正在写Xamarin应用程序,我发现WPF之间的区别,我无法跨越.
我正在使用Xamarin Forms Labs来控制Repeater.
我有一个Repeater,重复DataTemplate:
<DataTemplate>
<Button Text="{Binding Text}" Command="{Binding CategorySelectedCommand}" />
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
但我想将命令执行移动到我的userControl绑定上下文.
通常使用WPF,它看起来像:
Command={Binding ElementName=myUserControl, Path=DataContext.CategorySelectedCommand}
Run Code Online (Sandbox Code Playgroud)
但它没有ElementName属性.
我发现我可以像这样设置我的按钮的BindingContext:
BindingContext="{x:Reference myUserControl}"
Run Code Online (Sandbox Code Playgroud)
但后来我无法将Text属性绑定到我的按钮文本.
我该怎么做?
我正在尝试为多级菜单制作用户控件.我已经创建了第一级控件.它使用转发器进行迭代并实例化我自己的MenuButton类.每个MenuButton对象都具有相同类型的子项.
问题是:如何在MenuButton.aspx文件中创建MenuButton控件?
我正在使用这样的转发器
<%@ Control ClassName="MenuButton" Language="C#" AutoEventWireup="true" CodeBehind="MenuButton.ascx.cs"
Inherits="MenuSolution._12.TEMPLATE.CONTROLTEMPLATES.MenuButton, MenuSolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=284eb573cd58385d" %>
<%@ Register TagPrefix="a" Namespace="MenuSolution._12.TEMPLATE.CONTROLTEMPLATES"
Assembly="MenuSolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=284eb573cd58385d" %>
<li runat="server">
<% if (Children.Count == 0)
{ %>
<a href="<%# Url %>"><%# Description %></a>
<% }
else
{
%>
<a href="<%# Url %>" class="dropdown-toggle" data-toggle="dropdown">
<%# Description %><b class="caret"></b></a>
<ul class="dropdown-menu multi-level">
<asp:Repeater ID="repDynamicRows" runat="server">
<ItemTemplate>
<a:MenuButton runat="server" id="button" url='<%# DataBinder.Eval(Container.DataItem, "Url") %>'
children='<%# DataBinder.Eval(Container.DataItem, "ChildItems") %>' description='<%# DataBinder.Eval(Container.DataItem, "Description") %>' />
</ItemTemplate>
</asp:Repeater>
</ul> …Run Code Online (Sandbox Code Playgroud) 我正在尝试将自定义内容添加到Xamarin Forms中的按钮.
默认情况下,按钮创建如下:
<Button d:DataContext="{d:DesignInstance viewModel:AssessmentItemCategory}"
Clicked="Button_OnClicked"
Style="{StaticResource CategoryButtonStyle}"
Text={Binding Text} />
Run Code Online (Sandbox Code Playgroud)
但我想创建此按钮的自定义内容.通常使用WPF,我会这样做:
<Button d:DataContext="{d:DesignInstance viewModel:AssessmentItemCategory}"
Clicked="Button_OnClicked"
Style="{StaticResource CategoryButtonStyle}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Text}" Grid.Column="0" TextColor="Black"/>
<Label Text="-" Grid.Column="1" TextColor="Black"/>
</Grid>
</Button>
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
我也在寻找一个DataTemplate属性,但还没有找到它.
如何在Xamarin.Forms中做到这一点?
我想用WPF Prism + MahApps.Metro创建一个弹出窗口或对话框,确认选择(OK,Cancel)
我创建了自定义交互:
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding DeleteConfirmationRequest, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<confirmation:ConfirmationDialog/>
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
Run Code Online (Sandbox Code Playgroud)
但这将创建一个默认的WPF窗口,它不是城域风格的.如何将其更改为MahApps.Metro窗口?
也许,另一种方法是使用MahApps.Metro Dialogs,但我不知道如何将它与Prism一起使用.
有任何想法吗?
我在Unity游戏中验证SSL证书时遇到问题.
我制作了简单的测试代码:
ServicePointManager.ServerCertificateValidationCallback += ServerCertificateValidationCallback;
private static bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
public void Test()
{
WebClient w = new WebClient();
string downloadString = w.DownloadString("https://encrypted.google.com/");
}
Run Code Online (Sandbox Code Playgroud)
我已经在.NET 4.5和Unity(Mono)中实现了这个,问题是这个证书在.NET上得到了正确的验证,但在Mono中我得到了:
SslPolicyErrors: RemoteCertificateChainErrors
ChainStatus:
PartialChain
RevocationStatusUnknown
OfflineRevocation
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我应该在Mono中设置一些东西来处理吗?
谢谢
我有一个不透明度为0.4的div.如何让他的孩子不透明1?因为默认情况下它从父级获取不透明度.
例:
HTML:
<div class="container">
<div class="opacity">
<h2>TEST</h2>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和css:
.container{
height:200px;
background:yellow;
}
.opacity{
opacity: 0.3;
background:black;
height:100%;
width:40%
}
.opacity h2{
color:brown;
padding-left:15px;
padding-top:15px;
opacity:1;
}
Run Code Online (Sandbox Code Playgroud)
JsBin: JS Bin
如何让TEST完全可见?
我有一个 ListBox,它隐藏了 Horizontal ScrollBar。
我添加了自定义按钮,以控制此滚动(向左移动/向右移动)。
我想隐藏(将可见性设置为折叠)或如果 scrollViewer 不包含足够的项目来工作(当所有子项目都适合屏幕时)
在 WPF 中可能吗?
编辑:
基本上我的观点有点复杂,但我有这样的事情:
<ListBox x:Name="ListBox" Margin="0,0,10,0" Grid.Column="0" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="Transparent" ItemsSource="{Binding OpenedPatients}"
SelectedItem="{Binding SelectedPatient}">
...
...
</ListBox>
Run Code Online (Sandbox Code Playgroud)
我有代码隐藏控件:
private void ButtonBase1_OnClick(object sender, RoutedEventArgs e)
{
_scrollViewer = FindVisualChild<ScrollViewer>(ListBox);
_scrollViewer.LineLeft();
_scrollViewer.LineLeft();
_scrollViewer.LineLeft();
_scrollViewer.LineLeft();
_scrollViewer.LineLeft();
}
private void ButtonBase2_OnClick(object sender, RoutedEventArgs e)
{
_scrollViewer = FindVisualChild<ScrollViewer>(ListBox);
_scrollViewer.LineRight();
_scrollViewer.LineRight();
_scrollViewer.LineRight();
_scrollViewer.LineRight();
_scrollViewer.LineRight();
}
Run Code Online (Sandbox Code Playgroud)