绑定和样式不适用于 Win8? [英] Binding and style doesn't work for Win8?

查看:26
本文介绍了绑定和样式不适用于 Win8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个 TextBox 派生出来,并称它为 MyTextBox.在我的 LayoutAwarePage 上,我创建了 2 个 SolidColorBrush 道具:MyBackground 和 MyBorder.在该页面的 Xaml 中,我为控件 MyTextBox 编写了一个带有样式的 ResourceDictionary:

I derived from a TextBox and called it MyTextBox. On my LayoutAwarePage I created 2 SolidColorBrush props: MyBackground and MyBorder. In the Xaml of that page I wrote a ResourceDictionary with style to the control MyTextBox:

 <Grid.Resources>
        <ResourceDictionary>
            <Style TargetType="a:MyTextBox">
                <Setter Property="Background" Value="{Binding MyBackground}"></Setter>
                <Setter Property="BorderBrush" Value="{Binding MyBorder}"></Setter>
                <Setter Property="Width" Value="200"></Setter>
                <Setter Property="IsReadOnly" Value="False"></Setter>
                <Setter  Property="BorderBrush" Value="3"></Setter>
            </Style>
        </ResourceDictionary>
    </Grid.Resources>

当我运行这个页面时,我看不到控件.我没有忘记为页面创建一个DataContext,并且属性是真彩色(不是黑色).知道如何解决这个问题吗?

When I run this page I can't see the control. I didn't forget to create a DataContext for the page, and the properties are true colors (not black). Any idea how to solve this?

推荐答案

WinRT 不支持样式设置器中的绑定.

Binding in Style Setters is not supported in WinRT.

这篇关于绑定和样式不适用于 Win8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆