powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Silverlight верстка
3 сообщений из 3, страница 1 из 1
Silverlight верстка
    #37792429
Transplantator
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте, уважаемые форумчане.
Столкнулся со следующей проблемой : слил готовый xpsviewer и решил использовать в качестве основы своего приложения.
Изначально Mainpage.xaml выглядел так:

Код: xml
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.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  x:Class="SilverlightXPSViewer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    >
    <Grid x:Name="parentCanvas" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <ScrollViewer Background="{x:Null}" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="1,1,0,0" Width="640" Height="480" x:Name="xps_viewer" BorderBrush="{x:Null}" 
                      BorderThickness="0,0,0,0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Padding="0,0,0,0" Foreground="{x:Null}" Grid.RowSpan="2">
            <Grid Height="Auto" Width="Auto">
                <Canvas x:Name="page" Background="Transparent"  Width="Auto" Height="Auto" HorizontalAlignment="Stretch"   VerticalAlignment="Stretch" >
                    <Canvas x:Name="pageContents" Background="White" Canvas.Top="0">
                        <Canvas.RenderTransform>
                            <ScaleTransform x:Name="scaler" />
                        </Canvas.RenderTransform>
                    </Canvas>
                </Canvas>
            </Grid>
        </ScrollViewer>
        <StackPanel Orientation="Horizontal">
            <TextBox x:Name="txt_Url" Width="530" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <Button x:Name="btnshow" Width="50" Height="25" HorizontalAlignment="Right" VerticalAlignment="Top" Content="Show" Margin="0,0,10,0" Click="btnshow_Click" />
            <Button x:Name="btnbrows" Width="50" Height="25" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Brows" Margin="0,0,10,0" Click="btnbrows_Click" />
        </StackPanel>
        
        <Grid x:Name="controls" Width="400" Height="45" Margin="0,0,0,0" VerticalAlignment="Bottom" Opacity="0.85">
            <!-- Zoom controls -->
            <Rectangle x:Name="ctrl_bg" HorizontalAlignment="Stretch" Visibility="Collapsed">
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF626160"/>
                        <GradientStop Color="#FF2F2F2E" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Canvas x:Name="pageControls" Width="100" Height="24" VerticalAlignment="Center" HorizontalAlignment="Right">
                <Canvas x:Name="pagePrevious" MouseLeftButtonDown="Path_MouseLeftButtonDown"  Cursor="Hand" Canvas.Left="1.67" Canvas.Top="-0.313" Width="12.25" Height="24">
                    <Rectangle Width="17.458" Cursor="Hand" Height="24" Fill="#FF686868" Stroke="Gray" RadiusX="5" RadiusY="5" />
                    <Path Height="8.667" Width="8"  Cursor="Hand" Canvas.Left="2.48" Canvas.Top="8.338" Fill="#FFFFFFFF" Stretch="Fill" Data="M9.9800034,8.0883284 L9.9800034,15.754995 L2.9800074,11.546841 z"/>
                </Canvas>
                <Canvas x:Name="pageNext" MouseLeftButtonDown="Path_MouseLeftButtonDown_1"  Cursor="Hand" Canvas.Left="57.71" Canvas.Top="-0.313" Width="17.042" Height="24">
                    <Rectangle Width="17.125" Cursor="Hand" Height="24" Fill="#FF686868" Stroke="Gray" RadiusX="5" RadiusY="5" Canvas.Left="-0.25" />
                    <Path Height="8.667" Width="8" Cursor="Hand" Fill="#FFFFFFFF" Stretch="Fill"  Data="M9.9800034,8.0883284 L9.9800034,15.754995 L2.9800074,11.546841 z" Canvas.Left="7.23" Canvas.Top="8.255" RenderTransformOrigin="0.5,0.5">
                        <Path.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="-1"/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Path.RenderTransform>
                    </Path>
                </Canvas>
                <Canvas Canvas.Left="-7.002" Canvas.Top="-0.313" Width="65" Height="24">
                    <Rectangle Width="50" Height="24" Fill="#FFA2A2A2" Stroke="Gray" Canvas.Left="20.5" />
                    <TextBlock x:Name="pageInfo" Text="" FontSize="14" Canvas.Left="33.826" Canvas.Top="3.917" FontFamily="Verdana" Foreground="#FFFFFFFF" />
                </Canvas>
            </Canvas>
        </Grid>
        <Rectangle Height="30" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Fill="#FFFFFFFF" Stroke="#FF000000" Grid.Row="1" StrokeThickness="0.5" x:Name="footer"/>
        <Grid x:Name="zoomControls" Width="Auto" Height="Auto" VerticalAlignment="Bottom" Margin="4,3" Grid.RowSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid x:Name="statusControls" Margin="0">
                <Rectangle Height="25" Width="Auto" Canvas.Left="0.093" Canvas.Top="0.189" RadiusX="3" RadiusY="3" Fill="#FFA2A2A2" x:Name="rec_background"/>
                <TextBlock x:Name="statusText" VerticalAlignment="Center" FontSize="10.667" Canvas.Left="2" Canvas.Top="4" Text="" HorizontalAlignment="Left" Margin="5,0,0,0" FontFamily="Verdana">
                    <TextBlock.Clip>
                        <RectangleGeometry Rect="0,0,461,20" />
                    </TextBlock.Clip>
                </TextBlock>
            </Grid>
        </Grid>
        <StackPanel x:Name="zoomPanel" Orientation="Horizontal" Margin="10,3,0,20" VerticalAlignment="Bottom" HorizontalAlignment="Left">
            <Canvas x:Name="zoomIn" Cursor="Hand" Width="25" Height="20">
                <Image x:Name="ZoomIn" Source="Images/zoom_in.png" Height="Auto" Width="16"  Cursor="Hand" Canvas.Left="1.927" Canvas.Top="0.191"  Stretch="Uniform"/>
            </Canvas>
            <Canvas x:Name="zoomBar" Width="96.092" Height="20" Canvas.Top="1" Visibility="Collapsed">
                <Rectangle Width="100" Height="20" Fill="#FFFFFFFF" Stroke="#FF000000" />
                <Rectangle Width="98" Height="18" Canvas.Top="1" Canvas.Left="1" Fill="#FFDDDDDD" Clip="M0,18 L0,14 L98,1 L98,18"/>
                <Rectangle x:Name="zoomIndicator" Height="18" Canvas.Top="1" Canvas.Left="1" Fill="#FF000000" Clip="M0,18 L0,14 L98,1 L98,18"/>
            </Canvas>
            <Canvas x:Name="zoomOut" Cursor="Hand" Width="25" Height="20">
                <Image x:Name="ZoomOut" Height="Auto" Cursor="Hand"  Source="Images/zoom_out.png" Width="16" Canvas.Left="3.093" Canvas.Top="0.024"  Stretch="Uniform"/>
            </Canvas>
        </StackPanel>
    </Grid>
</UserControl>



После небольших изменений стало так:

Код: xml
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.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  x:Class="SilverlightXPSViewer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    >
    <Grid x:Name="parentCanvas" Background="Transparent" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid x:Name="grid_for_sc" Background="Transparent" ShowGridLines="True" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="50"/>
            </Grid.ColumnDefinitions>
            <ScrollViewer Background="{x:Null}"  Margin="1,25,0,0"  x:Name="xps_viewer" BorderBrush="BlueViolet" Height="800" Width="600" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                      BorderThickness="5,5,5,5" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled" Padding="0,0,0,0" Foreground="{x:Null}" Grid.RowSpan="1" Grid.ColumnSpan="1" Grid.Column="0" Grid.Row="0">
                <Canvas x:Name="page" Background="Transparent"  Width="Auto" Height="Auto" HorizontalAlignment="Stretch"   VerticalAlignment="Stretch" >
                    <Canvas x:Name="pageContents" Background="White" Canvas.Top="0">
                        <Canvas.RenderTransform>
                            <ScaleTransform x:Name="scaler" />
                        </Canvas.RenderTransform>
                    </Canvas>
                </Canvas>
            </ScrollViewer>
        </Grid>
        <StackPanel Orientation="Horizontal"  >
            <TextBox x:Name="txt_Url" Width="530" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <Button x:Name="btnshow" Width="50" Height="25" HorizontalAlignment="Right" VerticalAlignment="Top" Content="Show" Margin="0,0,10,0" Click="btnshow_Click" />
            <Button x:Name="btnbrows" Width="50" Height="25" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Brows" Margin="0,0,10,0" Click="btnbrows_Click" />
            <Button x:Name="btnprew" Width="50" Height="25" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Prew" Margin="0,0,10,0" Click="btnprew_Click" />
            <Button x:Name="btnadd" Width="50" Height="25" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Add" Margin="0,0,10,0" Click="btnadd_Click" />
        </StackPanel>
        <Grid x:Name="controls" Width="400" Height="45" Margin="0,0,0,0" VerticalAlignment="Bottom" Opacity="0.85" ShowGridLines="True">
            <!-- Zoom controls -->
            <Rectangle x:Name="ctrl_bg" HorizontalAlignment="Stretch" Visibility="Collapsed">
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF626160"/>
                        <GradientStop Color="#FF2F2F2E" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Canvas x:Name="pageControls" Width="100" Height="24" VerticalAlignment="Center" HorizontalAlignment="Right">
                <Canvas x:Name="pagePrevious" MouseLeftButtonDown="Path_MouseLeftButtonDown"  Cursor="Hand" Canvas.Left="1.67" Canvas.Top="-0.313" Width="12.25" Height="24">
                    <Rectangle Width="17.458" Cursor="Hand" Height="24" Fill="#FF686868" Stroke="Gray" RadiusX="5" RadiusY="5" />
                    <Path Height="8.667" Width="8"  Cursor="Hand" Canvas.Left="2.48" Canvas.Top="8.338" Fill="#FFFFFFFF" Stretch="Fill" Data="M9.9800034,8.0883284 L9.9800034,15.754995 L2.9800074,11.546841 z"/>
                </Canvas>
                <Canvas x:Name="pageNext" MouseLeftButtonDown="Path_MouseLeftButtonDown_1"  Cursor="Hand" Canvas.Left="57.71" Canvas.Top="-0.313" Width="17.042" Height="24">
                    <Rectangle Width="17.125" Cursor="Hand" Height="24" Fill="#FF686868" Stroke="Gray" RadiusX="5" RadiusY="5" Canvas.Left="-0.25" />
                    <Path Height="8.667" Width="8" Cursor="Hand" Fill="#FFFFFFFF" Stretch="Fill"  Data="M9.9800034,8.0883284 L9.9800034,15.754995 L2.9800074,11.546841 z" Canvas.Left="7.23" Canvas.Top="8.255" RenderTransformOrigin="0.5,0.5">
                        <Path.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="-1"/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Path.RenderTransform>
                    </Path>
                </Canvas>
                <Canvas Canvas.Left="-7.002" Canvas.Top="-0.313" Width="65" Height="24">
                    <Rectangle Width="50" Height="24" Fill="#FFA2A2A2" Stroke="Gray" Canvas.Left="21" />
                    <TextBlock x:Name="pageInfo" Text="" FontSize="14" Canvas.Left="45" Canvas.Top="3.917" FontFamily="Verdana" Foreground="#FFFFFFFF" />
                </Canvas>
            </Canvas>
        </Grid>
        <Rectangle Height="30" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Fill="#FFFFFFFF" Stroke="#FF000000" Grid.Row="1" StrokeThickness="0.5" x:Name="footer"/>
        <Grid x:Name="zoomControls" Width="Auto" Height="Auto" VerticalAlignment="Bottom" Margin="4,3" Grid.RowSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid x:Name="statusControls" Margin="0">
                <Rectangle Height="25" Width="Auto" Canvas.Left="0.093" Canvas.Top="0.189" RadiusX="3" RadiusY="3" Fill="#FFA2A2A2" x:Name="rec_background"/>
                <TextBlock x:Name="statusText" VerticalAlignment="Center" FontSize="10.667" Canvas.Left="2" Canvas.Top="4" Text="" HorizontalAlignment="Left" Margin="5,0,0,0" FontFamily="Verdana">
                    <TextBlock.Clip>
                        <RectangleGeometry Rect="0,0,461,20" />
                    </TextBlock.Clip>
                </TextBlock>
            </Grid>
        </Grid>
        <StackPanel x:Name="zoomPanel" Orientation="Horizontal" Margin="10,3,0,20" VerticalAlignment="Bottom" HorizontalAlignment="Left">
            <Canvas x:Name="zoomIn" Cursor="Hand" Width="25" Height="20">
                <Image x:Name="ZoomIn" Source="Images/zoom_in.png" Height="Auto" Width="16"  Cursor="Hand" Canvas.Left="1.927" Canvas.Top="0.191"  Stretch="Uniform"/>
            </Canvas>
            <Canvas x:Name="zoomBar" Width="96.092" Height="20" Canvas.Top="1" Visibility="Collapsed">
                <Rectangle Width="100" Height="20" Fill="#FFFFFFFF" Stroke="#FF000000" />
                <Rectangle Width="98" Height="18" Canvas.Top="1" Canvas.Left="1" Fill="#FFDDDDDD" Clip="M0,18 L0,14 L98,1 L98,18"/>
                <Rectangle x:Name="zoomIndicator" Height="18" Canvas.Top="1" Canvas.Left="1" Fill="#FF000000" Clip="M0,18 L0,14 L98,1 L98,18"/>
            </Canvas>
            <Canvas x:Name="zoomOut" Cursor="Hand" Width="25" Height="20">
                <Image x:Name="ZoomOut" Height="Auto" Cursor="Hand"  Source="Images/zoom_out.png" Width="16" Canvas.Left="3.093" Canvas.Top="0.024"  Stretch="Uniform"/>
            </Canvas>
        </StackPanel>
    </Grid>
</UserControl>



И теперь не работают кнопки, stackpanel стала неактивна. Уже второй день мучаюсь, но ничего не получается.
Подскажите, пожалуйста, в чем причина?
...
Рейтинг: 0 / 0
Silverlight верстка
    #37792493
SeVa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
У тебя сплошная избыточность
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
 <Grid Height="Auto" Width="Auto">
                <Canvas x:Name="page" Background="Transparent"  Width="Auto" Height="Auto" HorizontalAlignment="Stretch"   VerticalAlignment="Stretch" >
                    <Canvas x:Name="pageContents" Background="White" Canvas.Top="0">
                        <Canvas.RenderTransform>
                            <ScaleTransform x:Name="scaler" />
                        </Canvas.RenderTransform>
                    </Canvas>
                </Canvas>
            </Grid>


Канва в канве, да еще все это в гриду.
Всего две строки в основном гриде и большая куча элементов только в первой.
Для начала убери все canvas. Rectangle замени на бордюры. Это упростит код. Добовляй не все сразу, а поэлементно пока нет четкого понимания
...
Рейтинг: 0 / 0
Silverlight верстка
    #37793971
Transplantator
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
SeVa, спасибо.
Упростил конструкцию, убрал канвасы и все заработало.
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Silverlight верстка
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]