docs-desktop
docs-desktop copied to clipboard
Example code blocks are sometimes separated into 2 or more blocks
Example code is sometimes separated into 2 blocks, although could be displayed in the single block. This applies to multiple articles and multiple code languages. The publishing system can't merge two snippets into a single presented snippet block in the published article. The original authors tried to reuse portions of code which required them to use more than one code block, one after the other. Frankly, it looks terrible.
This issue is to track which articles have this problem and serve as a jumping off point for contributors to identify where to fix the issue.
Articles that need fixes:
- [ ] net/wpf/fundamentals/xaml.md
- [ ] framework/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior.md
- [ ] framework/wpf/controls/how-to-use-triggers-to-style-selected-items-in-a-listview.md
- [ ] framework/wpf/data/how-to-bind-to-a-collection-and-display-information-based-on-selection.md
- [ ] framework/wpf/data/how-to-set-up-notification-of-binding-updates.md
- [ ] framework/wpf/data/how-to-specify-the-binding-source.md
- [ ] framework/wpf/data/how-to-set-up-notification-of-binding-updates.md
- [ ] framework/wpf/data/data-templating-overview.md
- [ ] framework/wpf/controls/how-to-resize-columns-with-a-gridsplitter.md
- [ ] framework/wpf/controls/how-to-resize-rows-with-a-gridsplitter.md
Thank you for reporting this.
This is a common issue throughout the WPF documentation. Various parts of the XAML are reused and split out. We've recently adopted a model where we're just going to duplicate the XAML for each article instead of trying to reuse them as it causes problems like this.
Interesting that when I open page for editing on github, it has links to the code which are broken (or there is no access to them):
Is it possible to access them in order to make a fix by myself; or you have it somehow protected internally?
Thanks for the desire to contribute 👍
This is a actually a bit more complicated. First, a lot of the links don't work via github because of the syntax used. The #Source
link for example defines this in the source: ~/samples/snippets/csharp/VS_Snippets_Wpf/CollectionBinding/CSharp/Window1.xaml#source
with the ~
(to indicate the root) being the problem. To view the file in github you would need to adjust the URL in your browser (here is the link):
- https://github.com/dotnet/docs-desktop/blob/live/dotnet-desktop-guide/framework/wpf/data/~/samples/snippets/csharp/VS_Snippets_Wpf/CollectionBinding/CSharp/Window1.xaml#source
+ https://github.com/dotnet/docs-desktop/blob/live/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/CollectionBinding/CSharp/Window1.xaml#source
Snippet blocks are indicated with an XML comment containing an xml node (named of the snippet you want to define) that is open or closed open/close to indicate the snippet area. (if no # is used in the snippet reference in the doc, the whole file is presented on the published article)
So you can see the #source
snippet being defined here:
<!--<SnippetSource>-->
<Window x:Class="SDKSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SDKSample"
Title="Binding to a Collection"
SizeToContent="WidthAndHeight">
<Window.Resources>
<local:People x:Key="MyFriends"/>
<!--</SnippetSource>-->
The publishing system can't merge two snippets into a single presented snippet block in the published article. This is why it ends up being two distinct blocks and frankly looks terrible. The reason it's being displayed this way is that the source file contains a datatemplate that is being omitted in this reference because it's talked about in the next section of the article.
Really this XAML needs to be duplicated into two files, one to present the datatemplate and another to present the Source/UI snippets as a single one.
Thank you for the detailed explanation!
I think we should turn this into a project issue which is to identify and fix all of the individual articles that have this problem. I'm going to edit it to remove the metadata and then add links to each file identified via issues.
Same issue with this code. This can be resolved by using the triple backtick, however clicking "<>" in the rich text editor only gives a single backtick
` create or replace function my_function(months date[], some_other_var integer) returns setof foo
as $$
begin
return query
with f_months as (select distinct d from unnest(months) as d)
select
f.*
from foo f
inner join f_months cdate on
(f.effective_from is null or date_trunc('month', f.effective_from) <= date_trunc('month', cdate.d) )
and (f.effective_to is null or date_trunc('month', f.effective_to) > date_trunc('month', cdate.d) )
where
brg.some_other_var = some_other_var
and f.is_removed = false
and f.is_active = true;
end;
$$
language plpgsql;
-- Example: -- SELECT public.my_function(array['2020-10-01', '2020-09-01']::date[],10100);
`
Now with triple backticks
create or replace function my_function(months date[], some_other_var integer) returns setof foo
as $$
begin
return query
with f_months as (select distinct d from unnest(months) as d)
select
f.*
from foo f
inner join f_months cdate on
(f.effective_from is null or date_trunc('month', f.effective_from) <= date_trunc('month', cdate.d) )
and (f.effective_to is null or date_trunc('month', f.effective_to) > date_trunc('month', cdate.d) )
where
brg.some_other_var = some_other_var
and f.is_removed = false
and f.is_active = true;
end;
$$
language plpgsql;
-- Example:
-- SELECT public.my_function(array['2020-10-01', '2020-09-01']::date[],10100);
@netdragonboberb I'm not sure what article you're referencing. It doesn't seem though that it's related to WPF/WinForms which is what this repo is for?
Same issue with Structured navigation page: https://docs.microsoft.com/en-us/dotnet/desktop/wpf/app-development/structured-navigation-overview?view=netframeworkdesktop-4.8#creating-a-calling-page Some snippets have }
characters needlessly separated into another code block.