Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

#Unlearn WinForms.

Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


#Fine. What then?

Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

#Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


#Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

#Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


#Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

#Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


#Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

#Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


#Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

Source Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467

#Unlearn WinForms.

Your view has way too many concerns.

As @TeaDrivenDev mentioned, XAML is pretty verbose... and WPF bindings will turn your view model into a very combersome mess of getters and notifying setters... if you think in WinForms.

Dragging-and-dropping 100-some controls onto a UserForm creates ugly bloated code-behind in WinForms; (削除) there's no magic in WPF (削除ここまで) (well there is, actually), having a view with 100-some controls in WPF using databindings is bound (!) to create an ugly bloated view model class.


#Fine. What then?

Let's look at this UI.

stack panel with expander controls

Forget about the details, look at the high-level picture. What do you see? I see a StackPanel with a number of Expander controls. Nothing unmanageable here.

That's all your Window should care about.

You need to zoom out and stop seeing all the controls you want to see on that window, and break it down into reusable components.

I bet each expander has the same properties here:

<Expander Header="Processing" 
 HorizontalAlignment="Stretch"
 Margin="23,10,0.2,0" 
 VerticalAlignment="Top" 
 FontSize="20" 
 Foreground="#FFED8500" 
 Background="#FF585858" 
 FontWeight="SemiBold" 
 Name="exp2">

You probably don't need a Name for them. And if you do, you probably need an x:Name instead. But you probably don't. I rarely need to name controls in WPF. So the only thing that differs between each section here, is the Header text and the actual content. Right? Using a Style here would reduce the markup and make it semantically clearer that these UI elements should look the same.

Why not make a separate user control for each section, each with its own view model, dealing with its own data bindings?

default

AltStyle によって変換されたページ (->オリジナル) /