wpf

2009-02-03 10 views
9

में डिफ़ॉल्ट आकार बदलने की पकड़ को छुपाएं मेरे पास नीचे कुछ फैंसी सजावट के साथ, WPF में एक सीमाहीन और पारदर्शी विंडो है। कुछ गैर परंपरागत घटता और कंपनी लोगो को प्रदर्शित नहीं करने वाला एक कस्टम पाद लेख है। इस खिड़की को पारंपरिक खिड़कियों की तरह निचले दाएं कोने में पकड़ के साथ आकार बदलने योग्य होना चाहिए।wpf

वैसे भी, मैंने अपनी खुद की ResizeGrip को उस स्थान पर रखा है जो वास्तव में पाद लेख पर है, हालांकि डिफ़ॉल्ट पकड़ अभी भी दिखाई देती है और यह अदृश्य विंडो के कारण अंतरिक्ष में तैर रही है।

मैं डिफ़ॉल्ट ResizeGrip कैसे छिपा सकता हूं?

उत्तर

25

एक आकार बदलने की पकड़ विंडो पर ResizeMode निर्भरता संपत्ति के माध्यम से नियंत्रित की जाती है।

इस CanResizeWithGrip पर सेट है:

<Window x:Class="WpfApplication1.Window1" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Window1" Height="50" Width="150" 
     WindowStyle="None" AllowsTransparency="True" Background="#19FFFFFF" 
     ResizeMode="CanResizeWithGrip"> 
    <Grid></Grid> 
</Window> 

विंडो इस तरह दिखेगा:

With Grip

यह CanResize (डिफ़ॉल्ट) पर सेट है:

<Window x:Class="WpfApplication1.Window1" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Window1" Height="50" Width="150" 
     WindowStyle="None" AllowsTransparency="True" Background="#19FFFFFF" 
     ResizeMode="CanResize"> 
    <Grid></Grid> 
</Window> 

विंडो के रूप में दिखाई देगा इस प्रकार है:

Can Resize

+1

छवियां मर चुकी हैं। –

+0

@ सेबेस्टियन नेग्रसज़स मैंने कुछ नए जोड़े। –

18

तो डिफ़ॉल्ट पकड़ को छिपाने के लिए, मैं डिफ़ॉल्ट ResizeGrip शैली यह दृश्यता छिपा है ऐसी है कि अधिलेखित कर दिया। अभिव्यक्ति ब्लेंड 2.

<Style TargetType="{x:Type ResizeGrip}"> 
    <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/> 
    <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/> 
    <Setter Property="Background" Value="Transparent"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type ResizeGrip}"> 
       <Grid SnapsToDevicePixels="True" Background="{TemplateBinding Background}"> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
    <Setter Property="Visibility" Value="Hidden"/> 
</Style> 

की मदद से आसान तो मैं एक शैली है कि डिफ़ॉल्ट पकड़ शैली के समान है के साथ अपने कस्टम खिड़की सजावट पर अपने ही ResizeGrip की स्थापना की।

<SolidColorBrush x:Key="ResizeGripperForeground" Color="#B8B4A2"/> 
<Style x:Key="VisibleResizeGrip" TargetType="{x:Type ResizeGrip}"> 
    <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/> 
    <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/> 
    <Setter Property="Background" Value="Transparent"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type ResizeGrip}"> 
       <Grid SnapsToDevicePixels="True" Background="{TemplateBinding Background}"> 
        <Path Fill="White" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" Data="M 8,0 L 10,0 L 10,2 L 8,2 Z M 4,4 L 6,4 L 6,6 L 4,6 Z M 8,4 L 10,4 L 10,6 L 8,6 Z M 0,8 L 2,8 L 2,10 L 0,10 Z M 4,8 L 6,8 L 6,10 L 4,10 Z M 8,8 L 10,8 L 10,10 L 8,10 Z"/> 
        <Path Fill="{StaticResource ResizeGripperForeground}" HorizontalAlignment="Right" Margin="0,0,3,3" VerticalAlignment="Bottom" Data="M 8,0 L 10,0 L 10,2 L 8,2 Z M 4,4 L 6,4 L 6,6 L 4,6 Z M 8,4 L 10,4 L 10,6 L 8,6 Z M 0,8 L 2,8 L 2,10 L 0,10 Z M 4,8 L 6,8 L 6,10 L 4,10 Z M 8,8 L 10,8 L 10,10 L 8,10 Z"/> 
     <Path Data="M8,0L10,0 10,2 8,2z M4,4L6,4 6,6 4,6z M8,4L10,4 10,6 8,6z M0,8L2,8 2,10 0,10z M4,8L6,8 6,10 4,10z M8,8L10,8 10,10 8,10z" Fill="White" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" /> 
     <Path Data="M8,0L10,0 10,2 8,2z M4,4L6,4 6,6 4,6z M8,4L10,4 10,6 8,6z M0,8L2,8 2,10 0,10z M4,8L6,8 6,10 4,10z M8,8L10,8 10,10 8,10z" Fill="{StaticResource ResizeGripperForeground}" HorizontalAlignment="Right" Margin="0,0,3,3" VerticalAlignment="Bottom" /> 
     </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
+0

डाउनवोट झटका द्वारा ड्राइव के लिए धन्यवाद! – Jippers

+0

अच्छा एक। धन्यवाद Jippers। – Amsakanna

संबंधित मुद्दे