Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Re: Debug woes

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
Jason Dolinger
Guest


 

Re: Debug woes

Hi Michael et al,

Did you ever get a resolution to your problem? I'm having the same
issue, where I'm trying to develop a DataGrid as a custom control, and I
end up with a blank window with nothing displayed. My control and it's
associated children are clearly getting instantiated as I've debugged
through all of this, yet they are never displayed. I've put in a
Themes\Generic.xaml file which is referenced in the .csproj as a Page
include. Still nothing. The only thing I haven't done regarding the
instructions in this thread is to add the attribute:

[assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly)]

Exactly where am I supposed to place this attribute declaration?
Forgive me if that is a silly question, I've only been working with
C#/.NET/WPF for a few weeks now.

Any help is appreciated as always,
Jason


Michael Latta wrote:
> Thanks for the follow-up. This mostly answers my questions, with the
> addition of having to change the build task to Page from MarkupResource.
>
> If I want to provide different styles for my controls to be used in
> different themes how would I do that?
>
> If I have 10 XAML files all holding resource dictionaries it looks like I
> just create a <ResourceDictionary Source="foo.xaml"/> in the
> <MergedDictionaries> tag of the dictionary I want them to be added to. Is
> that correct? So both the reference and the definition have a
> ResourceDictionary element? Are the merged dictionaries loaded as loose
> XAML or compiled? Is there a performance hit for using merged dictionaries
> rather than one huge dictionary in compiled markup?
>
> Michael
>
>
> "Dennis Cheng [MSFT]" <dennis.cheng@online.microsoft.com> wrote in message
> news:%23q$irK39FHA.600@tk2msftngp13.phx.gbl...
>
>>From Ben Carter and Varsha Mahadevan on the Avalon team:
>>
>>
>>1. No they aren't loaded until you navigate to a page or load it up
>>programmatically using InitializeComponent.
>>
>>2. You need to explicitly merge ResourceDictionaries using the
>>ResourceDictionary.MergedDictionaries collection or then refer to them
>>individually using the ResourceDictionary.Source property.
>>
>>3. Resource lookup searches in the following order and stops at the first
>>match,
>> - In the tree
>> - In the app
>> - In the theme
>>
>>StaticResource and DynamicResources are different in the sense that
>>StaticResources are lexically scoped and are valid only in markup and use
>>the xml hierarchy for resolution (no forward references are permitted).
>>DynamicResources on the other hand understand logical treeness and get
>>resolved based on the runtime scope as described above. Also
>>StaticResources have one-time resolution semantics whereas
>>DynamicResources as the name suggested get updated on any contextual
>>change such as tree change or ResourceDictionary change.
>>
>>4. You also need to add the assembly level ThemeInfoAttribute metadata to
>>indicate what and where the theme dictionaries are located.
>>
>>For instance, if you only had generic.xaml compiled into the same assembly
>>in which the controls are defined, you would use:
>>[assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None,
>>ResourceDictionaryLocation.SourceAssembly)]
>>
>>
>>
>>"Michael Latta" <lattam@mac.com> wrote in message
>>news:u0GnVQG9FHA.2576@TK2MSFTNGP12.phx.gbl...
>>
>>>This may be the issue. The file does have the MarkupResource type
>>>currently. I will change it to page and see if that solves the issue.
>>>
>>>As a follow up:
>>>
>>>1) Are all page files loaded automatically?
>>>2) If I have 5 XAML files all with ResourceDictionary as the top element
>>>are they auto-merged into the assembly search path? Or do I need to
>>>explicitly merge the resource dictionaries in some way?
>>>3) Is there a definitive definition of how resources are located? When
>>>{StaticResource xxx} or {DynamicResource xxx} is used how is that
>>>resolved when there may be resources defined in the application, the
>>>window, and various control assemblies?
>>>4) It looks like in the old system the resources for the control library
>>>were included automatically. Do I need to do something to explicitly
>>>include those resources now?
>>>
>>>Michael
>>>
>>>
>>>
>>>"Dennis Cheng [MSFT]" <dennis.cheng@online.microsoft.com> wrote in
>>>message news:u7WMqzE9FHA.3880@TK2MSFTNGP12.phx.gbl...
>>>
>>>>Michael, how is the external ResourceDictionary containing the control
>>>>style included in your project? I'm thinking you're running into a
>>>>change in that removed the MarkupResource build action and replaced it
>>>>with Page:
>>>>
>>>>September 2005 CTP:
>>>> <MarkupResource Include="themes\generic.xaml"/>
>>>>
>>>>November 2005 CTP:
>>>> <Page Include="themes\generic.xaml"/>
>>>>
>>>>
>>>>"Michael Latta" <lattam@mac.com> wrote in message
>>>>news:uKrSc%23$7FHA.4012@TK2MSFTNGP14.phx.gbl...
>>>>
>>>>>It looks like my immediate issue is the control library assembly
>>>>>finding the resource dictionary. In the old template the file
>>>>>generic.xaml contained the resource dictionary for the assembly. In
>>>>>the Nov bits the assembly attributes for locating the resource
>>>>>dictionary have changed to using ResourceDictionaryLocation.
>>>>>Apparently the file name has changed or I am missing a piece to locate
>>>>>the file. I tried to create a new control library to see what the CTP
>>>>>creates, and this resolved the issue with the rename to
>>>>>ResourceDictionaryLocation, but the template for adding a new WinFX
>>>>>Custom Control is missing/broken so I can not get an example this way.
>>>>>Is there an overview on how resources are located, and in particular
>>>>>how custom control libraries locate the resources for the controls they
>>>>>define.
>>>>>
>>>>>Michael
>>>>>
>>>>>
>>>>>
>>>>>"Michael Latta" <lattam@mac.com> wrote in message
>>>>>news:uB%23lQr%237FHA.1184@TK2MSFTNGP12.phx.gbl...
>>>>>
>>>>>>In converting from Sept to Nov all my custom controls have
>>>>>>disappeared. The window comes up without the custom controls. They
>>>>>>are not even in the tree since surrounding elements do not make room
>>>>>>for them. And no messages regarding any errors come out. My main
>>>>>>issue is that there are no clues as to what went wrong. This seems
>>>>>>like very poor behavior in a file loader "oh those parts do not look
>>>>>>good so I am going to omit them silently". I have yet to verify if
>>>>>>they are actually instantiated and just are having styling problems,
>>>>>>but if there is an element in the logical tree that can not be
>>>>>>rendered into the visual tree there should be some way to debug that.
>>>>>>Any debug flags I can turn on somewhere to get more information on
>>>>>>what is happening?
>>>>>>
>>>>>>This is my main problem with WPF. Declarative programming is only a
>>>>>>good idea when it all works. Declarative programming with a huge
>>>>>>black box can be very frustrating. I really like WPF, but I also
>>>>>>really need some tools to examine what is going on in there. It is
>>>>>>understandable that they are not all there out of the box, but what
>>>>>>have other groups done (Sparkle, etc), to be able to tell what is
>>>>>>going on when things do not come out as expected?
>>>>>>
>>>>>>Michael
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>

>>

>
>

Old 01-10-2006   #2 (permalink)
Michael Latta
Guest


 

Re: Debug woes

I have it basically working now. The main thing was making the build task
Page.

The assembly attributes are in AssemblyInfo.cs under properties in my
project. I do not know if it has to be that exactly. It is marked as
Compile build task. So it appears to just be yet another C# source file.

Michael



"Jason Dolinger" <jdolinger@lab49.com> wrote in message
news:439DB50A.9020000@lab49.com...
> Hi Michael et al,
>
> Did you ever get a resolution to your problem? I'm having the same issue,
> where I'm trying to develop a DataGrid as a custom control, and I end up
> with a blank window with nothing displayed. My control and it's
> associated children are clearly getting instantiated as I've debugged
> through all of this, yet they are never displayed. I've put in a
> Themes\Generic.xaml file which is referenced in the .csproj as a Page
> include. Still nothing. The only thing I haven't done regarding the
> instructions in this thread is to add the attribute:
>
> [assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None,
> ResourceDictionaryLocation.SourceAssembly)]
>
> Exactly where am I supposed to place this attribute declaration? Forgive
> me if that is a silly question, I've only been working with C#/.NET/WPF
> for a few weeks now.
>
> Any help is appreciated as always,
> Jason
>
>
> Michael Latta wrote:
>> Thanks for the follow-up. This mostly answers my questions, with the
>> addition of having to change the build task to Page from MarkupResource.
>>
>> If I want to provide different styles for my controls to be used in
>> different themes how would I do that?
>>
>> If I have 10 XAML files all holding resource dictionaries it looks like I
>> just create a <ResourceDictionary Source="foo.xaml"/> in the
>> <MergedDictionaries> tag of the dictionary I want them to be added to.
>> Is that correct? So both the reference and the definition have a
>> ResourceDictionary element? Are the merged dictionaries loaded as loose
>> XAML or compiled? Is there a performance hit for using merged
>> dictionaries rather than one huge dictionary in compiled markup?
>>
>> Michael
>>
>>
>> "Dennis Cheng [MSFT]" <dennis.cheng@online.microsoft.com> wrote in
>> message news:%23q$irK39FHA.600@tk2msftngp13.phx.gbl...
>>
>>>From Ben Carter and Varsha Mahadevan on the Avalon team:
>>>
>>>
>>>1. No they aren't loaded until you navigate to a page or load it up
>>>programmatically using InitializeComponent.
>>>
>>>2. You need to explicitly merge ResourceDictionaries using the
>>>ResourceDictionary.MergedDictionaries collection or then refer to them
>>>individually using the ResourceDictionary.Source property.
>>>
>>>3. Resource lookup searches in the following order and stops at the first
>>>match,
>>> - In the tree
>>> - In the app
>>> - In the theme
>>>
>>>StaticResource and DynamicResources are different in the sense that
>>>StaticResources are lexically scoped and are valid only in markup and use
>>>the xml hierarchy for resolution (no forward references are permitted).
>>>DynamicResources on the other hand understand logical treeness and get
>>>resolved based on the runtime scope as described above. Also
>>>StaticResources have one-time resolution semantics whereas
>>>DynamicResources as the name suggested get updated on any contextual
>>>change such as tree change or ResourceDictionary change.
>>>
>>>4. You also need to add the assembly level ThemeInfoAttribute metadata to
>>>indicate what and where the theme dictionaries are located.
>>>
>>>For instance, if you only had generic.xaml compiled into the same
>>>assembly in which the controls are defined, you would use:
>>>[assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None,
>>>ResourceDictionaryLocation.SourceAssembly)]
>>>
>>>
>>>
>>>"Michael Latta" <lattam@mac.com> wrote in message
>>>news:u0GnVQG9FHA.2576@TK2MSFTNGP12.phx.gbl...
>>>
>>>>This may be the issue. The file does have the MarkupResource type
>>>>currently. I will change it to page and see if that solves the issue.
>>>>
>>>>As a follow up:
>>>>
>>>>1) Are all page files loaded automatically?
>>>>2) If I have 5 XAML files all with ResourceDictionary as the top element
>>>>are they auto-merged into the assembly search path? Or do I need to
>>>>explicitly merge the resource dictionaries in some way?
>>>>3) Is there a definitive definition of how resources are located? When
>>>>{StaticResource xxx} or {DynamicResource xxx} is used how is that
>>>>resolved when there may be resources defined in the application, the
>>>>window, and various control assemblies?
>>>>4) It looks like in the old system the resources for the control library
>>>>were included automatically. Do I need to do something to explicitly
>>>>include those resources now?
>>>>
>>>>Michael
>>>>
>>>>
>>>>
>>>>"Dennis Cheng [MSFT]" <dennis.cheng@online.microsoft.com> wrote in
>>>>message news:u7WMqzE9FHA.3880@TK2MSFTNGP12.phx.gbl...
>>>>
>>>>>Michael, how is the external ResourceDictionary containing the control
>>>>>style included in your project? I'm thinking you're running into a
>>>>>change in that removed the MarkupResource build action and replaced it
>>>>>with Page:
>>>>>
>>>>>September 2005 CTP:
>>>>> <MarkupResource Include="themes\generic.xaml"/>
>>>>>
>>>>>November 2005 CTP:
>>>>> <Page Include="themes\generic.xaml"/>
>>>>>
>>>>>
>>>>>"Michael Latta" <lattam@mac.com> wrote in message
>>>>>news:uKrSc%23$7FHA.4012@TK2MSFTNGP14.phx.gbl...
>>>>>
>>>>>>It looks like my immediate issue is the control library assembly
>>>>>>finding the resource dictionary. In the old template the file
>>>>>>generic.xaml contained the resource dictionary for the assembly. In
>>>>>>the Nov bits the assembly attributes for locating the resource
>>>>>>dictionary have changed to using ResourceDictionaryLocation.
>>>>>>Apparently the file name has changed or I am missing a piece to locate
>>>>>>the file. I tried to create a new control library to see what the CTP
>>>>>>creates, and this resolved the issue with the rename to
>>>>>>ResourceDictionaryLocation, but the template for adding a new WinFX
>>>>>>Custom Control is missing/broken so I can not get an example this way.
>>>>>>Is there an overview on how resources are located, and in particular
>>>>>>how custom control libraries locate the resources for the controls
>>>>>>they define.
>>>>>>
>>>>>>Michael
>>>>>>
>>>>>>
>>>>>>
>>>>>>"Michael Latta" <lattam@mac.com> wrote in message
>>>>>>news:uB%23lQr%237FHA.1184@TK2MSFTNGP12.phx.gbl...
>>>>>>
>>>>>>>In converting from Sept to Nov all my custom controls have
>>>>>>>disappeared. The window comes up without the custom controls. They
>>>>>>>are not even in the tree since surrounding elements do not make room
>>>>>>>for them. And no messages regarding any errors come out. My main
>>>>>>>issue is that there are no clues as to what went wrong. This seems
>>>>>>>like very poor behavior in a file loader "oh those parts do not look
>>>>>>>good so I am going to omit them silently". I have yet to verify if
>>>>>>>they are actually instantiated and just are having styling problems,
>>>>>>>but if there is an element in the logical tree that can not be
>>>>>>>rendered into the visual tree there should be some way to debug that.
>>>>>>>Any debug flags I can turn on somewhere to get more information on
>>>>>>>what is happening?
>>>>>>>
>>>>>>>This is my main problem with WPF. Declarative programming is only a
>>>>>>>good idea when it all works. Declarative programming with a huge
>>>>>>>black box can be very frustrating. I really like WPF, but I also
>>>>>>>really need some tools to examine what is going on in there. It is
>>>>>>>understandable that they are not all there out of the box, but what
>>>>>>>have other groups done (Sparkle, etc), to be able to tell what is
>>>>>>>going on when things do not come out as expected?
>>>>>>>
>>>>>>>Michael
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>

>>


Old 01-10-2006   #3 (permalink)
Jason Dolinger
Guest


 

Re: Debug woes

Thanks Michael,

Do you have something like this:

DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomControl18),
new FrameworkPropertyMetadata(typeof(MyCustomControl18)));

in a static constructor for your custom control?

Thanks,
Jason

Michael Latta wrote:
> I have it basically working now. The main thing was making the build task
> Page.
>
> The assembly attributes are in AssemblyInfo.cs under properties in my
> project. I do not know if it has to be that exactly. It is marked as
> Compile build task. So it appears to just be yet another C# source file.
>
> Michael
>
>
>
> "Jason Dolinger" <jdolinger@lab49.com> wrote in message
> news:439DB50A.9020000@lab49.com...
>
>>Hi Michael et al,
>>
>>Did you ever get a resolution to your problem? I'm having the same issue,
>>where I'm trying to develop a DataGrid as a custom control, and I end up
>>with a blank window with nothing displayed. My control and it's
>>associated children are clearly getting instantiated as I've debugged
>>through all of this, yet they are never displayed. I've put in a
>>Themes\Generic.xaml file which is referenced in the .csproj as a Page
>>include. Still nothing. The only thing I haven't done regarding the
>>instructions in this thread is to add the attribute:
>>
>>[assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None,
>>ResourceDictionaryLocation.SourceAssembly)]
>>
>>Exactly where am I supposed to place this attribute declaration? Forgive
>>me if that is a silly question, I've only been working with C#/.NET/WPF
>>for a few weeks now.
>>
>>Any help is appreciated as always,
>>Jason
>>
>>

Old 01-10-2006   #4 (permalink)
Michael Latta
Guest


 

Re: Debug woes

Yes, from the item template of a prior CTP, as below:

static ColorSelector()

{

//This OverrideMetadata call tells the system that this element

//wants to provide a style that is different than its base class.

//This style is defined in themes\generic.xaml

DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorSelector),

new FrameworkPropertyMetadata(typeof(ColorSelector)));

}

Michael

"Jason Dolinger" <jdolinger@lab49.com> wrote in message
news:439E07FC.9040406@lab49.com...
> Thanks Michael,
>
> Do you have something like this:
>
> DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomControl18),
> new FrameworkPropertyMetadata(typeof(MyCustomControl18)));
>
> in a static constructor for your custom control?
>
> Thanks,
> Jason
>
> Michael Latta wrote:
>> I have it basically working now. The main thing was making the build
>> task Page.
>>
>> The assembly attributes are in AssemblyInfo.cs under properties in my
>> project. I do not know if it has to be that exactly. It is marked as
>> Compile build task. So it appears to just be yet another C# source file.
>>
>> Michael
>>
>>
>>
>> "Jason Dolinger" <jdolinger@lab49.com> wrote in message
>> news:439DB50A.9020000@lab49.com...
>>
>>>Hi Michael et al,
>>>
>>>Did you ever get a resolution to your problem? I'm having the same
>>>issue, where I'm trying to develop a DataGrid as a custom control, and I
>>>end up with a blank window with nothing displayed. My control and it's
>>>associated children are clearly getting instantiated as I've debugged
>>>through all of this, yet they are never displayed. I've put in a
>>>Themes\Generic.xaml file which is referenced in the .csproj as a Page
>>>include. Still nothing. The only thing I haven't done regarding the
>>>instructions in this thread is to add the attribute:
>>>
>>>[assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None,
>>>ResourceDictionaryLocation.SourceAssembly)]
>>>
>>>Exactly where am I supposed to place this attribute declaration? Forgive
>>>me if that is a silly question, I've only been working with C#/.NET/WPF
>>>for a few weeks now.
>>>
>>>Any help is appreciated as always,
>>>Jason
>>>
>>>



Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to debug vbscript? Gene. VB Script 16 07-21-2008 09:44 PM
debug.txt go away keepout@yahoo.com.invalid Vista General 6 05-20-2008 11:02 PM
debug derek wilkie Live Mail 3 04-08-2008 04:57 PM
Wininet / Debug version? Rafael Rivera [Extended64.com] Vista General 0 11-12-2006 11:09 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50