Click here to Skip to main content
14,265,438 members

Silverlight / WPF

 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
Richard Deeming29-Aug-18 3:52
mveRichard Deeming29-Aug-18 3:52 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
Pew_new29-Aug-18 4:03
memberPew_new29-Aug-18 4:03 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
Richard Deeming29-Aug-18 4:09
mveRichard Deeming29-Aug-18 4:09 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
Pew_new29-Aug-18 4:31
memberPew_new29-Aug-18 4:31 
SuggestionRe: WPF: Customizing the appearence of a window n XAML Pin
Richard Deeming29-Aug-18 2:56
mveRichard Deeming29-Aug-18 2:56 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
Pew_new29-Aug-18 3:12
memberPew_new29-Aug-18 3:12 
QuestionWPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new21-Aug-18 5:13
memberPew_new21-Aug-18 5:13 
AnswerRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming21-Aug-18 9:59
mveRichard Deeming21-Aug-18 9:59 
Avoid layout out controls using margins, and avoid specifying a width and height for controls that don't need them.

For basic layout, use one of the standard layout panels, and use the horizontal and vertical layout properties to position your controls.

If you're creating a drawing, it's usually better to use the Canvas, and set the Canvas.Left and Canvas.Top positions instead.

If you want the drawing to resize with the container, you'll probably want a Viewbox as well.

Panels Overview | Microsoft Docs[^]
Canvas Class (System.Windows.Controls) | Microsoft Docs[^]
Viewbox | Microsoft Docs[^]

Eg:
<Grid ShowGridLines="True">
    <Grid.RowDefinitions>
        <RowDefinition Height="80"/>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="160"/>
    </Grid.RowDefinitions>

    <Canvas Grid.Row="1" HorizontalAlignment="Center" Width="1024" ClipToBounds="True">
        <!-- NB: No "Grid.Row" on the children; Margin replaced with Canvas.Left and Canvas.Top: -->
        <Path Data="M319.5,255.83333 L511.5,255.47633" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="1.357" Canvas.Left="255.468" Canvas.Top="175.5" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="193"/>
        ...
        <TextBlock x:Name="textBlock2" HorizontalAlignment="Left" Canvas.Left="387.968" Canvas.Top="10" Grid.Row="1" TextWrapping="Wrap" Text="Center vert. line of the 1024x768 screen" VerticalAlignment="Top"/>
    </Canvas>

    <!-- NB: No Margin, Width or Height; use horizontal and vertical alignment instead: -->
    <TextBlock x:Name="textBlock1" HorizontalAlignment="Center" TextWrapping="Wrap" Text="I need that Row" VerticalAlignment="Center" FontSize="24" TextAlignment="Center"/>
    <TextBlock x:Name="textBlock1_Copy" HorizontalAlignment="Center" TextWrapping="Wrap" Text="I need that Row" VerticalAlignment="Center" FontSize="24" TextAlignment="Center" Grid.Row="2"/>
</Grid>

With a Viewbox:
<Viewbox Grid.Row="1" HorizontalAlignment="Center" Stretch="Uniform" StretchDirection="Both">
    <Canvas Width="1024" Height="400">
        ...
    </Canvas>
</Viewbox>
(You'll probably need to play around with the canvas's height to get the result you want.)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new21-Aug-18 22:02
memberPew_new21-Aug-18 22:02 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming22-Aug-18 2:21
mveRichard Deeming22-Aug-18 2:21 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new23-Aug-18 0:41
memberPew_new23-Aug-18 0:41 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming23-Aug-18 8:15
mveRichard Deeming23-Aug-18 8:15 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new23-Aug-18 8:34
memberPew_new23-Aug-18 8:34 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming23-Aug-18 8:39
mveRichard Deeming23-Aug-18 8:39 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new23-Aug-18 8:52
memberPew_new23-Aug-18 8:52 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming23-Aug-18 9:05
mveRichard Deeming23-Aug-18 9:05 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new24-Aug-18 3:09
memberPew_new24-Aug-18 3:09 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Gerry Schmitz24-Aug-18 6:08
mveGerry Schmitz24-Aug-18 6:08 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new25-Aug-18 7:36
memberPew_new25-Aug-18 7:36 
QuestionScale items with ViewBox within an ItemsControl Pin
Kenneth Haugland7-Aug-18 6:07
professionalKenneth Haugland7-Aug-18 6:07 
AnswerRe: Scale items with ViewBox within an ItemsControl Pin
Kenneth Haugland8-Aug-18 3:56
professionalKenneth Haugland8-Aug-18 3:56 
QuestionPredicateBuilder Question Pin
Kevin Marois14-Jul-18 18:21
professionalKevin Marois14-Jul-18 18:21 
AnswerRe: PredicateBuilder Question Pin
Richard Deeming16-Jul-18 8:19
mveRichard Deeming16-Jul-18 8:19 
AnswerRe: PredicateBuilder Question Pin
Gerry Schmitz16-Jul-18 10:15
mveGerry Schmitz16-Jul-18 10:15 
QuestionWPF HyperLink Binding To MainWindowViewMOdel Not Working Pin
Kevin Marois9-Jul-18 17:02
professionalKevin Marois9-Jul-18 17:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.