首页 新闻 会员 周边 捐助

为什么我的程序在WP7模拟器中无法显示控件?

0
悬赏园豆:10 [已关闭问题] 关闭于 2012-09-08 16:58

以下程序在运行进名为“txtbl”的TextBlock控件无法显示

Silverlight项目:DataBindingDemo 文件:ElementNameDemo.xaml

....xmlns:local="clr-namespace:DataBindingDemo"...

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">             <TextBlock Height="30" HorizontalAlignment="Left" Margin="118,54,0,0" Name="txtblk" VerticalAlignment="Top" Width="210">                 <TextBlock.Text>                     <Binding ElementName="slider1" Path="Value">                         <Binding.Converter>                             <local:TruncationConverter/>                         </Binding.Converter>                     </Binding>                 </TextBlock.Text>             </TextBlock>             <Rectangle Height="200" HorizontalAlignment="Left" Margin="333,224,0,0" Name="rectangle1" Stroke="Yellow" StrokeThickness="1" VerticalAlignment="Top">                 <Rectangle.Width>                     <Binding ElementName="slider1" Path="Value"></Binding>                 </Rectangle.Width>                 <Rectangle.RenderTransform>                     <RotateTransform x:Name="rotate" Angle="90"/>                 </Rectangle.RenderTransform>             </Rectangle>             <Slider Height="256" HorizontalAlignment="Left" Margin="2,345,0,0" Name="slider1" VerticalAlignment="Top" Width="448"  Maximum="360"  />         </Grid>

 

隐藏文件:

 public ElementNameDemo()         {            

            InitializeComponent();             Binding binding = new Binding();             binding.ElementName = "rotate";             binding.Path = new PropertyPath("Angle");             binding.Mode = BindingMode.TwoWay;

BindingOperations.SetBinding(slider1, Slider.ValueProperty, binding);         }

TruncationConverter类: 

public class TruncationConverter:IValueConverter     {         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)         {             if (value is double)                 //将双精度浮点舍入为最接近的整数值                 return Math.Round((double)value);             return value;         }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)         {             return value;         }

傻小编的主页 傻小编 | 初学一级 | 园豆:190
提问于:2012-02-28 11:10
< >
分享
所有回答(1)
0

建议重新排一下版并加上描述问题的文字

dudu | 园豆:30757 (高人七级) | 2012-02-28 13:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册