Yeah sorry for that.. I guess I'm not a morning person

keep sending questions, helps me to understand the areas people have trouble
with :)
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Google Wave: portocarrero.i...@googlewave.com
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Fri, Nov 27, 2009 at 5:59 PM, Patrick Brown <patrickcbr...@gmail.com>wrote:

> Hi
>
>    Thank you, this explanation is very helpful.  I will start working on
> following the naming conventions, I have actually been purposefully avoiding
> them to this point as following the C# standards was helping me to map
> commonalities between the two languages and focus on learning the language
> and tools themselves.
>
> Thanks, I appreciate all of your help
> Patrick
>
> On Thu, Nov 26, 2009 at 3:48 AM, Ivan Porto Carrero 
> <i...@flanders.co.nz>wrote:
>
>> There is no link between the DLR objects and CLR objects so if you derive
>> from a control in ruby code there is no way for XAML to figure out what has
>> been configured etc. There is also no class it can link to as the classes
>> don't exist in the same way in a DLR based language as in a CLR language.
>>
>> The following control tries to make that integration easier but it's still
>> very early days and all help is wanted.
>> http://dynamicscriptcontrol.codeplex.com/
>> http://code.google.com/p/dynamic-script-control/
>>
>> Nick Rickets may be of help, I think he's got a WPF application with
>> IronRuby that is deployed AFAIK
>>
>> I think it's important to understand that there is a difference between a
>> DLR and a CLR based language. CLR classes map straight to CLR-types but this
>> isn't always the case in a DLR based language because they have a difference
>> on opinion with the CLR on how classes should behave.
>> The CLR says ALL classes are CLOSED that means you can't modify anything
>> once it's compiled then it only does its job and doesn't learn new tricks
>> The DLR (for IronRuby and IronPython at least) says ALL classes are OPEN,
>> you can freeze some making them closed.  Meaning once  you're program is
>> running you can modify classes by adding or removing methods and so on.
>> Because of this reason x:Class doesn't know where to go because for the
>> CLR the type may very well not exist.
>>
>> This doesn't help you much but it's a start to figure out what's going on
>> and why things don't work the same as with C#
>>
>>
>> I'm sorry but I keep deleting the following message from every email I
>> sent to help you:
>>
>> Naming conventions!
>> in ruby stuff is lowercased_and_underscored except for constants or there
>> is a particularly good reason for you to want an uppercased name like a DSL
>> entry point. UpperCased names are constants in Ruby and as such people
>> wanting to help you (in this case me) have an easier time getting through
>> your code as they don't have to workout what they are looking at. Constants
>> include ModuleNames, ClassNames and CONSTANT_VALUES
>>
>> in C# stuff is CamelCasedAndNotUnderscored.
>>
>> .
>>  ---
>> Met vriendelijke groeten - Best regards - Salutations
>> Ivan Porto Carrero
>> Blog: http://flanders.co.nz
>> Google Wave: portocarrero.i...@googlewave.com
>> Twitter: http://twitter.com/casualjim
>> Author of IronRuby in Action (http://manning.com/carrero)
>>
>>
>>
>>  On Wed, Nov 25, 2009 at 8:03 PM, Patrick Brown 
>> <patrickcbr...@gmail.com>wrote:
>>
>>>   Hello
>>>
>>>    Has anyone gotten a datatemplate for a ListView under WPF?  I created
>>> a very simple C# sample and converted it to IronRuby, the C# works
>>> perfectly, the IronRuby example displays my class name, the datatemplate
>>> didn't load and bind up to the properties as I hoped.
>>>
>>> C#
>>>     public class StatusListView : ListView
>>>     {
>>>         public StatusListView()
>>>         {
>>>             var items = new[]
>>>                 {
>>>                     new { message = "One", messageType = "Status" },
>>>                     new { message = "Two", messageType = "Error" },
>>>                     new { message = "Shree", messageType = "Status" }
>>>                 };
>>>             FrameworkElementFactory textblock = new
>>> FrameworkElementFactory(typeof(TextBlock));
>>>
>>>             Setter setter = new Setter();
>>>             setter.Property = TextBlock.FontSizeProperty;
>>>             setter.Value = 18.0;
>>>
>>>             DataTrigger dataTrigger = new DataTrigger();
>>>             dataTrigger.Binding = new Binding("messageType");
>>>             dataTrigger.Value = "Status";
>>>             dataTrigger.Setters.Add(setter);
>>>
>>>             Style style = new Style(typeof(TextBlock));
>>>             style.Triggers.Add(dataTrigger);
>>>
>>>             textblock.SetValue(TextBlock.StyleProperty, style);
>>>             textblock.SetBinding(TextBlock.TextProperty, new
>>> Binding("message"));
>>>             DataTemplate template = new DataTemplate();
>>>             template.VisualTree = textblock;
>>>             ItemsSource = items;
>>>             ItemTemplate = template;
>>>         }
>>>     }
>>>
>>>
>>>    IronRuby - in this sample my listview itemsource is actually set in
>>> another piece of code as so.  As I state above, the item does show up in the
>>> listview but the datatemplate is not applied against it.
>>>
>>> self.buildMessages = Array.new
>>> self.buildMessages.push(BuildMessage.new("Test","Status"))
>>> self.statusListView.ItemsSource = self.buildMessages
>>>
>>>
>>> class StatusListView < ListView
>>>  def initialize()
>>>   HorizontalAlignment = HorizontalAlignment.Stretch
>>>   Margin = Thickness.new(0,5,0,5)
>>>   MinHeight = 200
>>>
>>>   BuildItemTemplate()
>>>  end
>>>
>>>  def BuildItemTemplate()
>>>   begin
>>>    textblock = FrameworkElementFactory.new(TextBlock.to_clr_type)
>>>
>>>    setter = Setter.new
>>>    setter.Property = TextBlock.FontSizeProperty
>>>    setter.Value = 14.0
>>>
>>>    dataTrigger = DataTrigger.new
>>>    dataTrigger.Binding =
>>> System::Windows::Data::Binding.new("messageType")
>>>    dataTrigger.Value = "Status"
>>>    dataTrigger.Setters.Add(setter)
>>>
>>>    style = Style.new(TextBlock.to_clr_type)
>>>    style.Triggers.Add(dataTrigger)
>>>
>>>    textblock.SetValue(TextBlock.StyleProperty, style)
>>>    textblock.SetBinding(TextBlock.TextProperty,
>>> System::Windows::Data::Binding.new("message"))
>>>
>>>    template = DataTemplate.new
>>>    template.VisualTree = textblock
>>>    ItemTemplate = template
>>>   rescue Exception => e
>>>    puts "#{e}"
>>>   end
>>>  end
>>> end
>>>
>>> Thanks for your time and thoughts
>>> Patrick
>>>
>>> _______________________________________________
>>> Ironruby-core mailing list
>>> Ironruby-core@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/ironruby-core
>>>
>>>
>>
>> _______________________________________________
>> Ironruby-core mailing list
>> Ironruby-core@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/ironruby-core
>>
>>
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to