问题列表 - 第35016页

在Silverlight的ContentPresenter中将样式应用于TextBlocks

如果我定义了以下样式:

<UserControl.Resources>
    <Style TargetType="TextBlock" x:Key="ProblemStyle">
        <Setter Property="FontSize" Value="40"/>
        <Setter Property="FontWeight" Value="Bold"/>
    </Style>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)

然后,当我将ContentPresenter数据绑定到字符串时,在WPF中我可以使用以下XAML根据需要设置文本样式:

<ContentPresenter Content="{Binding Problem}">
    <ContentPresenter.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource ProblemStyle}" />
    </ContentPresenter.Resources>
</ContentPresenter>
Run Code Online (Sandbox Code Playgroud)

但是,在Silverlight中,这不起作用.有没有办法适用于两者?

silverlight wpf styles textblock contentpresenter

4
推荐指数
2
解决办法
5583
查看次数

封装在哪里?

我是一个新的程序员,所以请原谅这个问题的任何愚蠢,以下代码如何封装私有数据? -

public class SomeClass
{
    private int age;

    public int Age
    {
        get { return age; }
        set { age = value; }
    }

    public SomeClass(int age)
    {
        this.age = age;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的意思是,在属性中没有限制逻辑或过滤逻辑,上面的代码与下面的代码有什么不同 -

public class SomeClass
{
    public int age;

    public SomeClass(int age)
    {
        this.age = age;
    }
}
Run Code Online (Sandbox Code Playgroud)

第一个代码是否提供任何封装?

encapsulation field properties

5
推荐指数
1
解决办法
367
查看次数

Java 使用 inputmap 跟踪击键

我的代码遇到这个问题,我正在尝试学习如何在 Java 中使用击键,并且我希望能够跟踪我按下的击键。我正在尝试使用 KeyEvent.VK_UP 来跟踪我所按的内容。

import java.awt.event.*;
import javax.swing.*;

public class TrackArrows
{
    protected static InputMap inputMap;

    public static void main(String[] arg){
        JPanel panel = new JPanel();

        inputMap = panel.getInputMap();

        panel.getActionMap().put("keys", new AbstractAction() {
            public void actionPerformed(ActionEvent e){
                if(inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), true)){//My problem lies here
                    System.out.println("Key pressed up");
                }
                if(inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), true)){//And here
                    System.out.println("Key pressed down");
                }
            }
        });

        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "keys");
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "keys");

        JFrame frame = new JFrame();
        frame.getContentPane().add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(20,20);
        frame.setVisible(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

我这样做是错误的,还是有其他方法可以做到这一点?

java keystrokes

1
推荐指数
1
解决办法
6655
查看次数

Windows 7 shell函数的链接问题

我试图通过Windos 7库API枚举文件,例如使用SHLoadLibraryFromKnownFolder

我正在使用C++ win32控制台应用程序并获取链接错误,例如,

Error LNK2019: unresolved external symbol __imp__DSA_DestroyCallback@12 referenced in function "void __cdecl DSA_DestroyCallback(struct _DSA *,int (__stdcall*)(void const *,void *),void *)" (?DSA_DestroyCallback@@YAXPAU_DSA@@P6GHPBXPAX@Z2@Z)
Run Code Online (Sandbox Code Playgroud)

即使我只是出现这些错误 #include <ShlObj.h>

我应该在链接器输入中添加一些特定的库吗?谢谢,R.

c++ windows winapi linker windows-7

0
推荐指数
1
解决办法
167
查看次数

任何将'char'作为'unsigned'的编译器?

除非用户在文件或项目设置中明确提到,否则是否有任何C编译器将默认类型的char作为unsigned?

/ Kanu_

c compiler-construction signed char unsigned-char

5
推荐指数
1
解决办法
1989
查看次数

使用awk printf来urldecode文本

我正在使用awkurldecode一些文字.

如果我将字符串编码到printf语句中,就像printf "%s", "\x3D"正确输出一样=.如果我将整个转义字符串作为变量,则相同.

但是,如果我只有,我3D怎么能追加\x所以printf会打印=而不是\x3D

我正在使用busybox awk 1.4.2ashshell.

awk printf urldecode busybox

8
推荐指数
1
解决办法
6560
查看次数

Git推送到服务器

我们有一个网站,其所有PHP/HTML/JS/CSS/etc文件都存储在Git存储库中.

我们目前有3种类型的计算机(或用例)用于存储库.

  • 本地开发人员:提取最新更改,进行更改,提交本地仓库,推送到主服务器
  • 主服务器:中央存储库,所有更改都被推送到主服务器
  • Web服务器:部署网站时从主服务器下拉更改

所以目前我们:

local: git push origin master
local: password: ********
local: ssh admin@webserver.com
webserver: password: ********
webserver: cd ~/domain.com/
webserver: git pull origin master
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:有没有办法从我的本地电脑直接推送到网络服务器?

即.

local: git push origin master
local: password: ********
local: git push webserver master
local: password: ********
Run Code Online (Sandbox Code Playgroud)

git deployment push git-push git-remote

50
推荐指数
3
解决办法
6万
查看次数

Java中"this"的含义是什么?

通常,我this只在构造函数中使用.

我知道它用于识别参数变量(通过使用this.something),如果它与全局变量具有相同的名称.

但是,我不知道thisJava 的真正含义是什么,如果我this不使用dot(.)会发生什么.

java

127
推荐指数
8
解决办法
39万
查看次数

清漆:仅缓存特定域

我一直在谷歌搜索积极,但没有运气.

我正在使用Varnish,效果很好,但我想在一台服务器(Apache)上托管多个网站,而不使用Varnish缓存所有这些网站.

我可以通过URL指定要缓存的网站吗?

谢谢

apache dns performance varnish

15
推荐指数
2
解决办法
2万
查看次数

非常简单的问题c ++

刚刚开始学习c ++,我非常难以置信.它是一种令人惊叹的语言,但我在覆盖文件时遇到了一些麻烦

#include <iostream>
#include <fstream>

using namespace std;

int main( )
{
    double payIncrease = 7.6;
    double annual;


    double annualIncrease;
    double newAnnual;

    double monthlyIncrease;
    double newMonthly;

    ifstream inStream;
    ofstream outStream;
Run Code Online (Sandbox Code Playgroud)

//这是问题所在

        inStream.open("annualSalary.txt" );
        outStream.open("newAnnualSalary.txt");
Run Code Online (Sandbox Code Playgroud)

如果我将newAnnualSalary.txt更改为annualSalary.txt,我会得到一些非常奇怪的数字.有谁知道为什么?

    inStream >> annual;
    inStream.close();
    double monthly = (annual/12);

    annualIncrease = ((annual/100)*payIncrease);

    monthlyIncrease = ((monthly/100)*payIncrease);


    newMonthly = (monthly + monthlyIncrease);
    newAnnual = (annual + annualIncrease);




    outStream <<"annual salary was: "<<  annual << "\n" ;  
    outStream <<"new annual salary is " << newAnnual << "\n "; …
Run Code Online (Sandbox Code Playgroud)

c++ io

8
推荐指数
2
解决办法
353
查看次数