Code Monkey home page Code Monkey logo

gu.wpf.adorners's People

Contributors

dependabot[bot] avatar foggyfinder avatar forki avatar jbtje avatar johanlarsson avatar stevemonaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gu.wpf.adorners's Issues

IntelliSense XAML error: Watermark attachable properties not being found

Hello,

I'm currently using v2.1.1 installed via NuGet using Visual Studio Community 2019 (v16.9.3) in a WPF C# MVVM project (.NET Framework 4.7.2).

Project compiles as expected, but IntelliSense complains all the time about attachable properties not being found ("Text" and "VisibleWhen").

XAML code:

<UserControl x:Class="ardacam.Views.EditorSQL"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:adorners="http://gu.se/Adorners"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <GroupBox x:Name="GrupoBDs" Header="Bancos de Dados" HorizontalAlignment="Left" Height="55" Margin="0,10,0,0" VerticalAlignment="Top" Width="143">
            <ComboBox x:Name="comboBDs" HorizontalAlignment="Left" Height="23" Margin="7,7,0,0" VerticalAlignment="Top" Width="120" adorners:Watermark.Text="Selecione" adorners:Watermark.VisibleWhen="Empty">
            </ComboBox>
        </GroupBox>
        <GroupBox x:Name="GrupoQuery" Header="Consulta SQL" HorizontalAlignment="Left" Height="181" Margin="0,70,0,0" VerticalAlignment="Top" Width="790">
            <TextBox x:Name="InstrucaoSQL" HorizontalAlignment="Left" Margin="0,0,-2,7" TextWrapping="Wrap" AcceptsReturn="True" Text="" Width="780" Height="141" VerticalAlignment="Bottom"
                     adorners:Watermark.Text="It was a dark and stormy night. Watch your words..." adorners:Watermark.VisibleWhen="Empty" FontFamily="Courier New"/>
        </GroupBox>
        <GroupBox x:Name="GrupoConexaoManual" Header="Conexão Manual" HorizontalAlignment="Left" Height="55" Margin="148,10,0,0" VerticalAlignment="Top" Width="642">
            <Grid HorizontalAlignment="Left" Height="29" Margin="0,5,-2,-2" VerticalAlignment="Top" Width="632">
                <ComboBox x:Name="comboDriver" HorizontalAlignment="Left" Height="23" Margin="0,2,0,0" VerticalAlignment="Top" Width="62" 
                          adorners:Watermark.Text="Driver" adorners:Watermark.VisibleWhen="Empty">
                    <ComboBoxItem Content="Oracle" HorizontalAlignment="Left" Width="123"/>
                    <ComboBoxItem Content="SQL Server" HorizontalAlignment="Left" Width="123"/>
                    <ComboBoxItem Content="PostgreSQL" HorizontalAlignment="Left" Width="123"/>
                    <ComboBoxItem Content="MySQL" HorizontalAlignment="Left" Width="123"/>
                    <ComboBoxItem Content="Firebird" HorizontalAlignment="Left" Width="123"/>
                    <ComboBoxItem Content="InterSystems Caché" HorizontalAlignment="Left" Width="123"/>
                </ComboBox>
                <TextBox x:Name="Host" HorizontalAlignment="Left" Height="24" Margin="65,1,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="101" 
                         adorners:Watermark.Text="Host" adorners:Watermark.VisibleWhen="Empty"/>
                <TextBox x:Name="Porta" HorizontalAlignment="Left" Height="24" Margin="169,1,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="42" MaxLength="5"
                         adorners:Watermark.Text="Porta" adorners:Watermark.VisibleWhen="Empty" PreviewTextInput="ValidacaoInteiroTextBox" DataObject.Pasting="PastingHandler"/>
                <TextBox x:Name="Instancia" HorizontalAlignment="Left" Height="24" Margin="214,1,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="94" 
                         adorners:Watermark.Text="Instância" adorners:Watermark.VisibleWhen="Empty"/>
                <TextBox x:Name="Usuario" HorizontalAlignment="Left" Height="24" Margin="311,1,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="80" 
                         adorners:Watermark.Text="Usuário" adorners:Watermark.VisibleWhen="Empty"/>
                <PasswordBox x:Name="Senha" HorizontalAlignment="Left" Height="24" Margin="396,1,0,0" VerticalAlignment="Top" Width="80" 
                    adorners:Watermark.Text="Senha" adorners:Watermark.VisibleWhen="Empty"/>
            </Grid>

        </GroupBox>
        <GroupBox x:Name="GrupoResult" Header="Resultset" HorizontalAlignment="Left" Height="184" Margin="0,256,0,0" VerticalAlignment="Top" Width="790"/>
    </Grid>
</UserControl>

Error Code: XLS0415, 16 error occurrences in the aforementioned XAML code.

What I've tried to do to no avail:

  • Restart Visual Studio.
  • Delete .vs folder
  • Downgrade to v2.0.0
  • Upgrade again to v2.1.1

Is there anything else that can be done?

Thanks.

Watermark

I downloaded the latest version, and inserted into a user control
<UserControl x:Class="Helen.Controls.PasswordBoxControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:adorners="http://gu.se/Adorners"
xmlns:local="clr-namespace:Helen.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<PasswordBox x:Name="passwordBox" PasswordChanged="PasswordBox_PasswordChanged" adorners:Watermark.Text="Password"/>
</UserControl>
And the Watermark does not appears in intellisense and it's mark like wrong.
This application it's write in .net core 3.1

Hide watermark if control IsEnabled=false

It would be great if there was a way to set the Watermark to hidden if the control has InEnabled=False.

A couple options would be to enable a public setter on Watermark.IsVisible so it could be bound separately. Or add options to the VisibleWhen enum.

Thanks

How to implement TemplatedAdorner

Due to this we can't use àdornedElementPlaceHolder as it assumes it is in a TemplatedAdorner which is internal.

This leaves us with a couple of options:
1 Use reflection to new up a TemplatedAdorner.
2 Implement our own TemplatedAdorner and AdornedElementPlaceholder
3 Something clever.
4 An entirely new API.

I wrote 2 to see how it looks:

<Button>
    <adorners:Info.Template>
        <ControlTemplate>
            <Border Margin="-1"
                    BorderBrush="Red"
                    BorderThickness="1">
                <adorners:AdornedElementPlaceholder />
            </Border>
        </ControlTemplate>
    </adorners:Info.Template>
</Button>

I don't like that the caller must know that adorners:AdornedElementPlaceholder must be used, pit of failure.

Rewrote to use reflection now, not sure if it should be included.

Memory leak with attached events

It looks like the events used in the overlay keep the UIElements referenced even once they are unloaded. Suggest something like this to fix:

private static void OnUnLoaded(object sender, RoutedEventArgs e)
        {
        UpdateIsShowing(sender as DependencyObject);

            var element = sender as UIElement;
            if (element != null)
            {
                element.RemoveHandler(FrameworkElement.SizeChangedEvent, new RoutedEventHandler(OnSizeChanged));
                element.RemoveHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(OnLoaded));
                element.RemoveHandler(FrameworkElement.UnloadedEvent, new RoutedEventHandler(OnUnLoaded));
                element.RemoveHandler(Visible.IsVisibleChangedEvent, new RoutedEventHandler(OnIsVisibleChanged));
            }
        }

Crash sometimes use adorners:Info for DataGridRow.

The crash log is below:

System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 MS.Internal.Controls.TemplatedAdorner.MeasureOverride(Size constraint)
   在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   在 System.Windows.UIElement.Measure(Size availableSize)
   在 System.Windows.Documents.AdornerLayer.MeasureOverride(Size constraint)
   在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   在 System.Windows.UIElement.Measure(Size availableSize)
   在 System.Windows.ContextLayoutManager.UpdateLayout()
   在 System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   在 System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   在 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   在 System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   在 System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

And I use adorners:Info for DataGridRow like below :

<DataGrid.RowStyle>
    <Style BasedOn="{StaticResource DataGridRowDefault}" TargetType="DataGridRow">
        <Setter Property="adorners:Info.IsVisible">
            <Setter.Value>
                <MultiBinding Converter="{StaticResource Equal2BoolConverter}">
                    <Binding
                        Mode="OneWay"
                        Path="DataContext"
                        RelativeSource="{RelativeSource Self}" />
                    <Binding
                        ElementName="PageRoot"
                        FallbackValue="{x:Null}"
                        Mode="OneWay"
                        Path="DataContext.CurrentLowestPriceSellOrder" />
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="adorners:Info.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border
                            HorizontalAlignment="Stretch"
                            BorderBrush="{DynamicResource PrimaryBrush3}"
                            BorderThickness="0,0,0,1">
                            <AdornedElementPlaceholder />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</DataGrid.RowStyle>

The DataGridRow Info.IsVisible is based on the equility of the row's DataContext and an ParentView's DataContext property(named CurrentLowestPriceSellOrder).

Because It doesn't happen very often, I wonder if there was a memory leak. Looking forward to your reply!

Adorners layer shows through other controls?

The adorner shows through slide-in panels - any way to stop this - have played around with a few things but the adorner still show through?

Perhaps you could shed some light on this or a work-around?

Thanks

Daniel

Issue when using Overlay inside a Zoombox

Having the following minimal code sample in a plain WPF window.

    xmlns:adorn="http://gu.se/Adorners"
    xmlns:geo="http://gu.se/Geometry"
   ...
   <geo:Zoombox>
        <Rectangle
            Width="50"
            Height="50"
            Fill="Red">
            <adorn:Overlay.Content>
                <Border BorderBrush="Green" BorderThickness="10" />
            </adorn:Overlay.Content>
        </Rectangle>
    </geo:Zoombox>
  1. When zooming (mouse wheel) or dragging, the size and position of the Overlay (green border) stays the same. It refreshes e.g. when changing the position of the whole window. How can I force the Overlay to refresh as soon as the Zoombox has changed it's zoom or position?
  2. The Zoombox's features do not work if the mouse is above the Overlay (green border). Setting the border IsHitTestVisible="False" solves that problem, but in some scenarios I cannot do that (for I need to handle some mouse events). Is there a way to have IsHitTestVisible="True" and still forward the UI-events to the Zoombox so that I can do it's job?

Generalized watermark

Improvement suggestion:

The watermark adorner looks great, however it seems like there is a limitation in terms of what it can display. I have a use-case where I want to show a magnifier glass symbol before the text "Search". In order to display the magnifier glass I need to be able to set the font family to Segoe MDL2 Assets. This does not appear possible in the current implementation. Do you like the idea of having a TextBlock property type here?

Here's how I do it with the current buggy watermark implementation I use:

<TextBox Text="{Binding Path=Foo}">
    <uc:WatermarkService.Watermark>
        <TextBlock>
            <Run FontFamily="Segoe MDL2 Assets" Text="&#xE721;" />
            <TextBlock Text="Search">
                <TextBlock.RenderTransform>
                    <TranslateTransform Y="-1" />
               </TextBlock.RenderTransform>
            </TextBlock>
       </TextBlock>
   </uc:WatermarkService.Watermark>
</TextBox>

Background for Info

Not sure is it correct behaviour, TextBox is not visible itself

        <TextBox Name="MyTextBox" adorners:Info.IsVisible="{Binding ElementName=MyTextBox, Path=IsFocused}">
            <adorners:Info.Template>
                <ControlTemplate>
                    <Border Padding="5" BorderThickness="1" 
                            Background="Gray"
                            BorderBrush="LightGreen">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <AdornedElementPlaceholder />
                            <TextBlock Grid.Row="1"  Text="Sample" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </adorners:Info.Template>
        </TextBox>

Screen:

bck

TextBlock adorner

Hi, I've added addorner for TextBlock but it doesn't render. Do I have to use TextBox? I wasn't sure from the usage guide whether only TextBox, PasswordBox and ComboBox are supported, or whether it should work for any control. Thanks.

DragAdorner snap to

public Vector OffsetTo(Visual target)

And

public void SnapTo(Visual target)

IsVisible vs Visibility in Readme.md documentation

I cannot bind .IsVisible as described by the samples shown by Overlay and Info since IsVisible is read-only.

<Rectangle
	adorners:Info.IsVisible="True"

Results in the error message: Error MC3065 'Info.IsVisible' property is read-only and cannot be set from markup.

I believe they should be changed to .Visibility as mentioned by the 2.0 breaking change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.