我是WPF编程的.在DataGrid控件中,我需要一种方法来制作单元格的中心内容.我也使用这个代码:
<DataGrid x:Name="dg1" HorizontalAlignment="Left" Margin="10,10,0,0"
VerticalAlignment="Top" Height="360" Width="498"
FontFamily="2 Badr" FontSize="18"
AlternatingRowBackground="LightCoral" FlowDirection="RightToLeft"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Background="{x:Null}"/>
Run Code Online (Sandbox Code Playgroud)
怎么了?
我能做什么?
请在XAML(Just XAML)中提供您的答案.
我使用此代码进行Android(Java)编程:
public static MessageBoxResult showOk(
Context context, String title, String message, String okMessage)
{
okDialogResult = MessageBoxResult.Closed;
// make a handler that throws a runtime exception when a message is received
final Handler handler = new Handler()
{
@Override
public void handleMessage(Message mesg)
{
throw new RuntimeException();
}
};
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle(title);
alert.setMessage(message);
alert.setPositiveButton(okMessage, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
okDialogResult = MessageBoxResult.Positive;
handler.sendMessage(handler.obtainMessage());
}
});
AlertDialog dialog = alert.show();
// align button …Run Code Online (Sandbox Code Playgroud) 我需要一种在c#中定义方法的方法,如下所示:
public String myMethod(Function f1,Function f2)
{
//code
}
Run Code Online (Sandbox Code Playgroud)
设f1为:
public String f1(String s1, String s2)
{
//code
}
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
我使用DataSet在WPF(C#)中填充DataGrid.结果是:

我想删除左侧的空白列.我想与列共享剩余空间.预期结果是:

我的XAML代码是:
<Window x:Class="RFID.CareerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="CareerWindow" Height="356" Width="404">
<Grid>
<DataGrid x:Name="dg1" HorizontalAlignment="Left" Margin="25,10,0,0" VerticalAlignment="Top" Height="306" Width="355" EnableRowVirtualization="false" EnableColumnVirtualization="false" FontFamily="2 badr" FontSize="20" FlowDirection="RightToLeft" CanUserAddRows="False" CanUserReorderColumns="False"/>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud) 我正试图每秒刷新标签内容.所以我定义了两种方法如下.我startStatusBarTimer()在我的构造函数中使用Window.
代码:
private void startStatusBarTimer()
{
System.Timers.Timer statusTime = new System.Timers.Timer();
statusTime.Interval = 1000;
statusTime.Elapsed += new System.Timers.ElapsedEventHandler(statusTimeElapsed);
statusTime.Enabled = true;
}
private void statusTimeElapsed(object sender, ElapsedEventArgs e)
{
lblNow.Content = DateTime.Now.ToString("yyyy/MM/dd");
}
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
调用线程无法访问此对象,因为另一个线程拥有它.
怎么了?或者我该怎么办?
我是WPF的新手(c#).我需要在图像控制周围使用发光效果triggers.如何对mouse-enter事件进行发光效果?我想用我的风格来回答你的问题.
我的效果是:
<DropShadowEffect x:Key="MyEffect" ShadowDepth="0" Color="Blue" Opacity="1" BlurRadius="20"/>
Run Code Online (Sandbox Code Playgroud)
我看到很多链接,但它们不起作用.
我正在使用WPF(c#)编写程序.我用几个按钮.点击它后,Anny按钮开始闪烁!它的颜色从背景颜色渐变为浅蓝色(淡蓝色).当我点击另一个按钮时,它不会停止闪烁(然后此按钮开始闪烁!!!).这是一个错误吗?它与我的视觉工作室有关吗?
我该如何解决这个问题?
我正在尝试使用C#(Windows窗体)中的EmguCV 3.1(OpenCV库的点.NET包装器)实现多层感知器(MLP)神经网络.为了练习这个库我决定OR使用MLP 实现操作.
我使用"初始化"方法创建MLP并使用"Train"方法学习它,如下所示:
private void Initialize()
{
NETWORK.SetActivationFunction(
ANN_MLP.AnnMlpActivationFunction.SigmoidSym);
NETWORK.SetTrainMethod(ANN_MLP.AnnMlpTrainMethod.Backprop);
Matrix<double> layers = new Matrix<double>(new Size(4, 1));
layers[0, 0] = 2;
layers[0, 1] = 2;
layers[0, 2] = 2;
layers[0, 3] = 1;
NETWORK.SetLayerSizes(layers);
}
private void Train()
{
// providing data for input
Matrix<float> input = new Matrix<float>(4, 2);
input[0, 0] = MIN_ACTIVATION_FUNCTION; input[0, 1] = MIN_ACTIVATION_FUNCTION;
input[1, 0] = MIN_ACTIVATION_FUNCTION; input[1, 1] = MAX_ACTIVATION_FUNCTION;
input[2, 0] = MAX_ACTIVATION_FUNCTION; input[2, 1] = MIN_ACTIVATION_FUNCTION;
input[3, 0] = …Run Code Online (Sandbox Code Playgroud) 我正在使用WPF(C#)编写程序.我使用这样的方法来打开和关闭窗口:
public static void openCloseWindow(Window toBeOpen, Window toBeClose)
{
toBeOpen.Show();
makeWindowCenter(toBeOpen);
toBeClose.Close();
}
Run Code Online (Sandbox Code Playgroud)
在程序的一部分我使用这样的方法:
openCloseWindow(new BestCustomerWindow,this);
Run Code Online (Sandbox Code Playgroud)
因此,最终用户可以在按钮上多次单击,并且可以打开许多窗口.
有没有办法避免在运行时打开窗户?
欲获得更多信息:
让我点击一个打开window1的按钮.我想要:
我尝试在 WPF(c#) 中创建自定义 MessageBox。我需要将 MessageBoxImage 转换为 ImageSource。有什么办法吗?