小编kiz*_*ore的帖子

将图像加载到writeablebitmap中

所以我试图将图像加载到WriteableBitmap但我得到一个NullReferenceException.无法弄清楚为什么因为我以前认为这曾经工作过

BitmapImage b = new BitmapImage(new Uri(@"images/Car.jpg", Urikind.Relative)); WriteableBitmap wb = new WriteableBitmap(b);

而已.我将汽车图像作为我项目中的资源.它工作正常,因为我可以创建一个Image控件并将其源设置为BitmapImage并显示它.谢谢

c# silverlight writeablebitmap

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

使用内部html的id属性创建angularjs指令,但仍然在外部html上使用id

所以我创建了这个复选框指令,它由一个标签和输入元素组成.我想在指令上设置一个id属性,并将其设置为input元素的"id"和标签"for"属性.这工作正常,但问题是它仍然在外部html上,这是一个div,所以它打破了我的指令.我认为如果您将指令设置为replace:true,那么这将删除定义该指令的html.

该指令如下

angular.module('journal.directives', []).
  directive('fancyCheckbox', function(){
  return {
    restrict : 'EA', 
    replace : true,
    template : '<div class="fancyCheckbox">' +
           '<input type="checkbox" id="{{ id }}" />' +
           '<label for="{{ id }}" ></label>' +
           '</div>',
    scope : {
      colour : '@',
      id : '@', 
    },
    link : function(scope, elem, attrs){
      var spotColourClass;
      var valid_colours = ['blue', 'green', 'gray', 'purple', 
              'blue', 'orange', 'charcoal', 'light',
                  'yellow', 'red'];

      if(valid_colours.indexOf(scope.colour) !== -1){                   
      spotColourClass = scope.colour + "spot";
      }else{
        spotColourClass = 'greenspot';
      }

    elem.addClass(spotColourClass);
    }
  };
}); …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive

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

Dependency property not updating usercontrol ui

I have a usercontrol which has a couple of textblocks on it

<UserControl x:Class="Tester.Messenger"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         x:Name="myUserControl"
         >  
<TextBlock Text="{Binding ElementName=myUserControl,Path=Header,Mode=TwoWay}" Foreground="LightGray" FontSize="11"  Margin="3,3,0,-3"/>
<TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="{Binding ElementName=myUserControl,Path=Message, Mode=TwoWay}" Foreground="White" FontSize="16" Margin="3,-5"/>
Run Code Online (Sandbox Code Playgroud)

In my code behind I have two dependency properties that I'm binding the above textblocks Text property to.

public static readonly DependencyProperty HeaderProperty =
        DependencyProperty.Register("HeaderProperty", typeof(string), typeof(UserControl), new PropertyMetadata("header"));

    public static readonly DependencyProperty MessageProperty =
        DependencyProperty.Register("MessageProperty", typeof(string), typeof(UserControl), new PropertyMetadata(null));


 public string Header
    { …
Run Code Online (Sandbox Code Playgroud)

silverlight wpf user-controls dependency-properties

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