标签: converter

如何手动更新多重绑定

我遇到了问题Binding.在Rectangle.Fill依赖属性被绑定到ObservableCollection与转换器.虽然ObservableCollection工具INotifyCollectionChanged,绑定没有更新.但是,我设法通过将我的代表团附加到集合的更改通知事件并手动刷新绑定来解决此问题:

    void ColorsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
        BindingExpression b = colorRectangle.GetBindingExpression(Rectangle.FillProperty);
        if (b != null)
            b.UpdateTarget();
    }
Run Code Online (Sandbox Code Playgroud)

不过最近,我改变了BindingMultiBinding,并将上述溶液停止工作(的bIS null).有没有办法强制Multibinding更新目标属性?

最好的问候 - 幽灵.

c# wpf converter multibinding

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

是否可以自动将Java代码转换为PHP?

是否有工具将java代码转换为PHP?我有java库的源代码,我需要它转换为PHP.

php java converter

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

用于将多个SVG图像转换为SVG字体文件的脚本

我正在搜索一个脚本,将多个SVG图像(每个包含一个字母)转换为SVG字体文件.

这个网站的基本相同:http://keyamoon.com/icomoon/app/

但我更喜欢一个脚本(更喜欢Linux),所以我们可以将它集成到我们的构建过程中.

有任何想法吗?或者我可以开始的代码?

输入应该是SVG图像列表+映射文件,输出应该是包含所有SVG图像的一个文件作为SVG字体.

linux fonts svg converter svg-font

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

不使用内置bin函数将整数转换为二进制

该函数作为参数接收整数,并且应该返回表示以二进制表示的相同值的列表作为位列表,其中列表中的第一个元素是最重要(最左侧)位.

我的功能目前输出'1011'数字11,我需要[1,0,1,1].

例如,

>>> convert_to_binary(11)
[1,0,1,1]
Run Code Online (Sandbox Code Playgroud)

python binary list converter bit

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

如何实现BoolToVisibilityConverter

在我的应用程序中,我想切换StackPanel中项目的可见性.我的Stackpanel包含一个Image和一个TextBlock.如何正确使用BoolToVisibilityConverter切换TextBlock的可见性,并为用户的利益保存此设置?

目前我的情况如下,虽然我收到了一些错误.重要提示,我需要使用ApplicationBar菜单项作为单击事件来驱动TextBox可见性的切换.

编辑

尽管TextBlock的可见性未发生变化,但不再出现错误.

XAML

xmlns:common="clr-namespace:TestApp.Common"

<phone:PhoneApplicationPage.Resources>
    <common:BooleanToVisibilityConverter x:Key="BoolToVisConv" />
</phone:PhoneApplicationPage.Resources>

<ListBox Name="ListBoxEffects" SelectionMode="Single" ItemsSource="{Binding}" Margin="{Binding}"
                     toolkit:TiltEffect.IsTiltEnabled="True" SelectionChanged="ListBox_SelectionChanged" 
                         ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel ItemWidth="159" ItemHeight="Auto" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical"  >
                                <Image Source="{Binding Thumbnail}" Width="155" Height="155" />
                                <TextBlock Text="{Binding Name}" Visibility="{Binding IsTextBlockVisible, Converter={StaticResource BoolToVisConv}}"  TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
Run Code Online (Sandbox Code Playgroud)

代码背后

private void BuildLocalizedApplicationBar()
    {
        ApplicationBar = new ApplicationBar();

        ApplicationBarMenuItem showFilterNamesMenuItem = new ApplicationBarMenuItem();
        if (Settings.ShowFilterNames.Value)
            showFilterNamesMenuItem.Text = AppResources.EditPage_EffectNames_Hide;
        else
            showFilterNamesMenuItem.Text = AppResources.EditPage_EffectNames_Show;
        showFilterNamesMenuItem.Click …
Run Code Online (Sandbox Code Playgroud)

c# xaml converter windows-phone-7 windows-phone-8

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

在python中将字符串转换为十六进制

我有一个脚本调用一个函数,该函数采用十六进制数作为参数.参数需要0x前缀.数据源是一个数据库表,存储为字符串,因此返回"0x77".我正在寻找一种从数据库中获取字符串的方法,并将其用作带有0x前缀的十六进制形式的参数.

这有效:

addr = 0x77
value = class.function(addr)
Run Code Online (Sandbox Code Playgroud)

数据库条目必须是一个字符串,因为大多数其他记录在此列中没有十六进制值,但可以更改这些值以使其更容易,因此代替"0x77",它可能是"119".

python hex converter

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

如何为数据表的每一行设置转换器属性?

我创建了自定义ISO日期时间Converter:

public class IsoDateTimeConverter implements Converter, StateHolder {

    private Class type;
    private String pattern;

    private boolean transientValue = false;

    public void setType(Class type) {
        this.type = type;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
        if (StringCheck.isNullOrEmpty(value)) {
            throw new ConverterException("value not specified");
        }

        try {
            if (IsoDate.class.equals(type)) {

                if (WebConst.ISO_DATE_NONE.equals(value)) {
                    return IsoDate.DUMMY;
                } else {
                    //TODO User spezifische TimeZone auslesen
                    return new …
Run Code Online (Sandbox Code Playgroud)

datatable jsf converter jsf-2

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

将类stdClass的Object转换为JSON Object

这是我的PHP文件中的内容:

$session = $m->session;
Run Code Online (Sandbox Code Playgroud)

$ session现在是:

object(stdClass)[31]
  public 'id' => string '21112' (length=5)
  public 'external_id' => string '' (length=0)
  public 'sessiongroupid' => string '1843' (length=4)
  public 'eventid' => string '5588' (length=4)
  public 'order' => string '0' (length=1)
  public 'name' => string 'Ferdau Conference' (length=17)
  public 'description' => string 'Ferdau Conference' (length=17)
  public 'starttime' => string '2013-04-18 18:00:00' (length=19)
  public 'endtime' => string '2013-04-18 18:04:00' (length=19)
  public 'speaker' => string '' (length=0)
  public 'location' => string 'Waregem' (length=7)
  public 'mapid' => …
Run Code Online (Sandbox Code Playgroud)

javascript php json converter object

12
推荐指数
1
解决办法
3万
查看次数

在Swift中将String转换为CLLocationCoordinate2D

使用Firebase作为我的后端,我有一系列的经纬度坐标字符串,如何将它们转换为CLLocationCoordinate2D以便我可以使用它们进行注释?以下是每次更新时从Firebase获取信息的代码

var UpdateRef = Firebase(url:"https://ici.firebaseio.com/users")

UpdateRef.observeEventType(.ChildChanged, withBlock: { (snapshot) in
    let MomentaryLatitude = snapshot.value["latitude"] as? String
    let MomentaryLongitude = snapshot.value["longitude"] as? String
    let ID = snapshot.value["ID"] as? String

    println("\(MomentaryLatitude)")

    var Coordinates = CLLocationCoordinate2D(latitude: MomentaryLatitude as
        CLLocationDegrees, longitude: MomentaryLongitude as CLLocationDegrees)

}
Run Code Online (Sandbox Code Playgroud)

最后一行不起作用,我应该使用什么呢?

string converter cllocation cllocationcoordinate2d swift

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

使用JSF转换器输出时,使用指定值替换null或空字符串

以下是一个转换器,主要用于修剪前导和尾随空格,并用一个空格替换句子中的单词或文本之间的多个空格.现在修改转换器以null使用"不可用" 替换或清空字符串(如果需要,可以动态本地化).

@FacesConverter(forClass = String.class)
public class StringTrimmer implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return Boolean.TRUE.equals(component.getAttributes().get("skipConverter")) ? value : value == null ? null : value.trim().replaceAll("\\s+", " ");
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return Boolean.TRUE.equals(component.getAttributes().get("skipConverter")) ? value == null ? null : value.toString() : value == null || ((String) value).trim().length() == 0 ? "Not available" : ((String) value).trim().replaceAll("\\s+", " ");
    }
}
Run Code Online (Sandbox Code Playgroud)

由于未调用转换器,因此当模型值null基于 …

string null jsf converter

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