Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

ContentControl becomes slow after showing a ComboBox drop down

$
0
0

WPF applications can be resized very quickly until a CombBox drop down is shown. This is most apparent when the application uses many ContentControl instances. This is best demonstrated with a sample application. Do the following to recreate the issue...

1 - Create  new WPF Application.

2 - Replace the XAML content for the control with the XAML at the end of this post.

3 - Run the application and use the mouse to resize the window, it should be quick and crisp.

4 - Use the drop down arrow on the ComboBox at the top of the window to show its drop down.

5 - Use the mouse to resize the window, it is now significantly slower. The scale of the slowdown
     depends on your machine. On my development machine it is only update 3 or 4 times per 
     second but other developers in the office get better results.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
       
        <ComboBox Width="100" HorizontalAlignment="Left"/>
       
        <StackPanel Grid.Row="1" Orientation="Vertical">
            <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
            <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
            <ContentControl><Button Content="Hello"/></ContentControl>
            </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
            </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
            <StackPanel Orientation="Vertical">
                <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
                <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
                <ContentControl><Button Content="Hello"/></ContentControl>
                </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
                </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
                <StackPanel Orientation="Vertical">
                    <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
                    <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
                    <ContentControl><Button Content="Hello"/></ContentControl>
                    </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
                    </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
                    <StackPanel Orientation="Vertical">
                        <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
                        <ContentControl><ContentControl><ContentControl><ContentControl><ContentControl>
                        <ContentControl><Button Content="Hello"/></ContentControl>
                        </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
                        </ContentControl></ContentControl></ContentControl></ContentControl></ContentControl>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Grid>

C# - Create a wpf design by a picture

$
0
0
Hi.
I have found a picture of a wpf window in one of msdn tutorial and Im trying to copy the design for my progect (School progect).
The picture I found is: (found here)
The picture of what I have made until now is (In replays down)
First I have been trying to make the window backgound  look the same as the window border withe this code: this.Background = System.Windows.SystemColors.ActiveCaptionBrush;
but you can see that dosen't worked (so please help!).
Second can you please help me make the border/canvas at the side(The white one) to be as the same angle as the border/canvas at the first picture (I tried to do that with viewport2Dvisual3D with no secsess).


---N.M---
P.S
Sorry about my English :)




WPF Auto complete text box. Please Help!

$
0
0

Hi There, 

i am trying to create an auto complete textbox from a list of string. i dont want the auto correction to be a list, i just want it to auto suggest the rest of the word in the actual textbox.

Any ideas would be great!

regards


james

Vscroll in tabcontrol

$
0
0

hi all

I have tabpage I want add vertical scroll in it but I my code didn't successful

 
tabpage.VerticalScroll.Visible = True
tabpage.VerticalScroll.Enabled = True
tabpage.AutoScroll = True
is there anymetod to insertvscroll to tabpage ??

Update Combobox ItemsSource

$
0
0

I have two combo boxes: cboContinents and cboCountries.

In cboContinents_ValueChanged event, I have: 

selectedContinent = cboContinents.Text.ToString();

List<string>lstCountries = MyClass.GetListOfCountries(selectedContinent);

cboCountries.ItemsSource = lstCountries;

The above logic seems to be working okay as the drop-down list associated with cboCountries is updated. HOWEVER, when an item in cboCountries is selected and I select another control, the text in cboCountries is automatically replaced by another item. It's like the index of the item is not matched with the value..

Pls help.

Displaying search results having strings and URLs in WPF application

$
0
0

I am building a WPF application to search items. In the hundreds of search results, every result is of 2 or 3 elements which would be string and URL for that item. I have displayed the results obtained in a data grid view. But I want the URL obtained to redirect to that particular site which as of now is just a plain result.

Since one search result may/ may not have 2-3 search elements, how to display the result and show the URL as a hyperlink?

Can i combine one search result (i.e. 2-3 search elements of a result)  and move it in a text block and thus adding text blocks dynamically in the data grid view? If yes, then how is it possible and how can the hyperlink be defined then?

Memory consumption of WPF application in TaskManager

$
0
0

Hi there,

I am doing a WPF application. When I am running the application and check for the Memory consumption in TaskManager, it is getting gradual increase when we do some operations. I am messed up whether this is the behavior of WPF controls or I did something wrong.

Let me say an example:
I am having two textboxes that contains some values and two buttons.
When I click one of the button, the value of 1st TextBox copied to another. And on click of another button, the reverse (copying from 2nd to 1st) happens.
On each every click the Memory consumption increases. (The case includes ListBox, etc.,..)
Please give me some assistance.

Thanks in advance

  KSAM

How to interop WPF PrintDialog and the MFC print dialog

$
0
0

We have a MFC application. And we added an WPF assembly to be hosted in this application. The MFC application already implemented printing using MFC printing dialog. Now, we want to use the  same MFC printing dialog to print the WPF content, how can we pass those printing settings (from MFC printing dialog) to WPF? The WPF has it's own PrintDialog class. Anyway to interop the WPF PrintDialog and the MFC printing dialog?


ValidationEngine for attaching Validation Binding for entire WPF Application

$
0
0
Hi,

I want to create a ValidationEngine which would bear following responsibility;

1. Bind Validation Rule to entire Control in a WPF Application 

2. Explicit calling for any Validation.

3. Provide a Central XML for Rule Configuration for entire application.

4. Show Count for all failed Validations.

5. Provide Validation Binding for ItemsControl and all Child control validation through this Engine.

What would be the Limitations and Benefits for any such Validation Framework?

Is there any such Validaion Framework exists which able to fulfill all the above requirement

Regards,

Abhishek

How to make a HwndSource transparent with Child window style

$
0
0

Hi,

I want to show some WPF controls above a Win32 window, so I use HwndSource to host the WPF control, and show it as a Child window of the Win32 window. Now I want to make the WPF control transparent, so that I can see the background of the Win32 window, so I set the UsesPerPixelOpacity to true on the HwndSource window, but I find  that this property only works if the HwndSource is a top-level window which means it must have the WS_POPUP instead of WS_CHILD, and this is not what I want. So is there any way to make the WPF control transparent and be a child of the Win32 window?

-Dominic


Dominic Zhang

How do we make read only all controls in a tab control?

$
0
0

We're working with VS 2012, .NET 4.5. There will be times when we've got to prevent the user from adding or editing data on the user controls that we're writing. Our user controls will all have one main tab control, with other container controls within each TabItem control (things like dock panels, grids,  stack panels, etc.) Like others we've discovered that the TabControl doesn't have a IsReadOnly property. I've searched for ways of preventing users from either adding new data or editing existing data, and have seen suggestions like defining a DependencyProperty for the TabControl which could be assessable from controls on the TabItem controls, but that seems like a lot of XAML coding to accomplish. And I've seen an example where the questioner had something like 6 textboxes in a TabItem, and the person who answered it iterated over the collection of content of the TabItem, and set each of the textbox's IsReadOnlyProperty to true. That to me looked like it would work fine, if all you have were textboxes in a TabItem. But since we'll have controls within other container controls I would think we'd have to recursively go into each container, or am I wrong about that?

Another thing is we'll be working with more than TextBoxes. We're going to also be working with CheckBoxes, ComboBoxes and an assortment of Telerik controls (RadGridView, etc.) Controls like the Checkbox doesn't have a IsReadOnly property; so the appropriate property, in the Checkbox case, would be IsEnabled. Bottom line is, assuming we use some way of iterating over the collection of controls in a TabItem, we have to have a way of differentiating between the different types of controls. How is that done? And do we have to recursively enter every container control, or will iterating over the collection of controls within the TabItem content be sufficient to visit each control there, regardless of whether or not it's in a container or not?


Rod

How to use Windows Forms FontDialog in WPF?

$
0
0
I'm trying it with windowsFormsHost but it wont let me because it's not a control.

Is it possible?

"Untoggle" a CustomControl's ToggleButton when some event is raised

$
0
0

We're building this MediaPlayerControl:

It has no logic. We will use this control in some parts of application. We defined Commands for it and bound them to the buttons of the control:

public static class MediaPlayerCommands
    {
        public static readonly RoutedUICommand TogglePlay =
            new RoutedUICommand("Tocar/Pause", "TogglePlay", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand ForwardFive =
            new RoutedUICommand("Avançar 5 segundos", "ForwardFive", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand ForwardTen =
            new RoutedUICommand("Avançar 10 segundos", "ForwardTen", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand RewindFive =
            new RoutedUICommand("Retroceder 5 segundos", "RewindFive", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand RewindTen =
            new RoutedUICommand("Retroceder 10 segundos", "RewindTen", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand StartPosition =
            new RoutedUICommand("Posição inicial", "StartPosition", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand EndPosition =
            new RoutedUICommand("Posição final", "EndPosition", typeof(MediaPlayerControl));
        public static readonly RoutedUICommand ToggleLoop =
            new RoutedUICommand("Continuamente", "ToggleLoop", typeof(MediaPlayerControl));
    }

So, when the user click the "play" ToggleButton, wherever the command is implemented, it will be executed. However, if for some reason, the actually media (some video) is paused, how can I "untoggle" the play ToggleButton? You see, it was not the user that clicked to pause... it was some event in the application that occured, and we need to "untoggle" the play button


Take a look at WPF FlashMessage
About.me


wpf: problem with scrollbar style

$
0
0
Hi guys, i really hope you can help me with the small problem. I managed to style the vertical scrollbar but i cannot manage to style horizontal scrolbar. 
i dont understand why? can you please review my code. i may have missed something. i will appreicate your code help. thanks so much. 

<Grid.Resources>
       <ResourceDictionary Source="/Menu\styles\test.xaml"></ResourceDictionary>
      </Grid.Resources>

    <ListBox HorizontalAlignment="Center" Width="196" Style="{DynamicResource ListBoxStyle1}" Margin="310,170,419,361">
        <ListBoxItem Content="fgfdgsdfgsdfgsdfgsdfg"/>
        <ListBoxItem Content="dfgsdfgsdfgsdfgsdfgsdfgsdfgsdfgsdfgsdfg"/>
        <ListBoxItem Content="Frafgsdfgsdfgsdfgdfgsdfgsdfgsdfgdfgdfgsnce"/>
        <ListBoxItem Content="Frafgsdfgsdfgsdfgdfgsdfgsdfgsdfgdfgdfgsnce"/>
        <ListBoxItem Content="Frafgsdfgsdfgsdfgdfgsdfgsdfgsdfgdfgdfgsnce"/>
        <ListBoxItem Content="Frafgsdfgsdfgsdfgdfgsdfgsdfgsdfgdfgdfgsnce"/>
        <ListBoxItem Content="Frafgsdfgsdfgsdfgdfgsdfgsdfgsdfgdfgdfgsnce"/>
        <ListBoxItem Content="Frafgsdfgsdfgsdfgdfgsdfgsdfgsdfgdfgdfgsnce"/>
    </ListBox>

<SolidColorBrush x:Key="ListBorder" Color="#828790"/>
<!--LISTBOX-->
<Style x:Key="ListBoxStyle1" TargetType="{x:Type ListBox}">
    <Setter Property="BorderBrush" Value="#FF1C93F5"/>
    <Setter Property="BorderThickness" Value="5"/>
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
    <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
    <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListBox}">
                <Grid>
                    <Rectangle Fill="#FF1F1E1E" RadiusX="10" RadiusY="1" Opacity="0.195" />
                    <Border CornerRadius="10" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1" SnapsToDevicePixels="true">
                        <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}" Template="{DynamicResource ScrollViewerControlTemplate1}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                    </Trigger>
                    <Trigger Property="IsGrouping" Value="true">
                        <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<!--  SCROLL VIEWER  -->
<ControlTemplate x:Key="ScrollViewerControlTemplate1"
                  TargetType="{x:Type ScrollViewer}">
  <Grid x:Name="Grid"
        Background="{TemplateBinding Background}">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                            Grid.Column="0"
                            Margin="{TemplateBinding Padding}"
                            CanContentScroll="{TemplateBinding CanContentScroll}"
                            CanHorizontallyScroll="False"
                            CanVerticallyScroll="False"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}" />
    <!--  vertical scrollbar  -->
    <ScrollBar x:Name="PART_VerticalScrollBar"
                Grid.Column="1"
                AutomationProperties.AutomationId="VerticalScrollBar"
                Cursor="Hand"
                Maximum="{TemplateBinding ScrollableHeight}"
                Minimum="0"
                Style="{DynamicResource ScrollBarStyle1}"
                ViewportSize="{TemplateBinding ViewportHeight}"
                Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                Value="{Binding VerticalOffset,
                                Mode=OneWay,
                                RelativeSource={RelativeSource TemplatedParent}}" />
    <!-- NEW BIT -->
    <ScrollBar x:Name="PART_HorizontalScrollBar"
                Grid.Row="1"
                Grid.Column="0"
                AutomationProperties.AutomationId="HorizontalScrollBar"
                Cursor="Hand"
                Maximum="{TemplateBinding ScrollableWidth}"
                Minimum="0"
                Orientation="Horizontal"
                Style="{DynamicResource ScrollBarStyle1}"
                ViewportSize="{TemplateBinding ViewportWidth}"
                Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                Value="{Binding HorizontalOffset,
                                Mode=OneWay,
                                RelativeSource={RelativeSource TemplatedParent}}" />
  </Grid>
</ControlTemplate>


<!--LISTBOX ITEM-->
<Style TargetType="{x:Type ListBoxItem}">
    <Setter Property="Foreground" Value="White" />
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
    <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
    <Setter Property="Padding" Value="2,0,0,0"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                    </Trigger>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsSelected" Value="true"/>
                            <Condition Property="Selector.IsSelectionActive" Value="false"/>
                        </MultiTrigger.Conditions>
                        <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                    </MultiTrigger>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<!--SCROLLBAR BUTTON-->
<Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


<!--SCROLL BAR THUMB-->
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Thumb}">
                <Rectangle Width="8" Fill="White" RadiusX="5" RadiusY="5">
                    <Rectangle.Effect>
                        <DropShadowEffect ShadowDepth="0" BlurRadius="10" Color="White" />
                    </Rectangle.Effect>
                </Rectangle>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>



<!--VERTICAL SCROLLBAR BACKGROUND-->
<LinearGradientBrush x:Key="VerticalScrollBarBackground" EndPoint="1,0" StartPoint="0,0">
    <GradientStop Color="#E1E1E1" Offset="0"/>
    <GradientStop Color="#EDEDED" Offset="0.20"/>
    <GradientStop Color="#EDEDED" Offset="0.80"/>
    <GradientStop Color="#E3E3E3" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ScrollBarDisabledBackground" Color="#F4F4F4"/>

<!--VERTICAL SCROLLBAR PAGE BUTTON-->
<Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
                <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<!--HORIZONTAL SCROLLBAR BACKGROUND-->
<LinearGradientBrush x:Key="HorizontalScrollBarBackground" EndPoint="0,1" StartPoint="0,0">
    <GradientStop Color="#E1E1E1" Offset="0"/>
    <GradientStop Color="#EDEDED" Offset="0.20"/>
    <GradientStop Color="#EDEDED" Offset="0.80"/>
    <GradientStop Color="#E3E3E3" Offset="1"/>
</LinearGradientBrush>

<!--HORIZONTAL SCROLLBAR PAGE BUTTON-->
<Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
                <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<!--SCROLLBAR STYLE-->
<Style x:Key="ScrollBarStyle1" TargetType="{x:Type ScrollBar}">
    <!--STYLE FOR VERTICAL-->
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
    <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
    <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>


    <!--TEMPLATE FOR VERTICAL-->
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ScrollBar}">
                <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                    <Border Width="1" Background="#FFFFFF" HorizontalAlignment="Center"/>
                    <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}">

                        <Track.Thumb>
                            <Thumb Style="{StaticResource ScrollBarThumb}"/>
                        </Track.Thumb>
                    </Track>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Style.Triggers>

        <!--ORIENTATION = HORIZONTAL-->
        <Trigger Property="Orientation" Value="Horizontal">
            <Setter Property="Width" Value="Auto"/>
            <Setter Property="MinWidth" Value="0"/>
            <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
            <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
            <Setter Property="Background" Value="{StaticResource HorizontalScrollBarBackground}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <!--FOR HORIZONTAL-->
                    <ControlTemplate TargetType="{x:Type ScrollBar}">
                        <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                <ColumnDefinition Width="0.00001*"/>
                                <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                            </Grid.ColumnDefinitions>
                            <RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}" />
                            <Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                </Track.DecreaseRepeatButton>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                </Track.IncreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource ScrollBarThumb}"/>
                                </Track.Thumb>
                            </Track>
                            <RepeatButton Grid.Column="2" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Trigger>
    </Style.Triggers>
</Style>

ItemContainerGenerator GenerateNext and Recycling

$
0
0

Hi,

I am writing my custom virtualizing panel and I stumbled upon Generator. I realized however wishes to create such a virtualizing panel, they will need the Generator and its GenerateNext method for generating the visible items to the user.

Now my question is, what will happen inside the hood of ItemControlGenerator when I run GenerateNext over an area that has been already generated/realized but noone of the realized containers was ever removed or recycled by the generator?

With removed/recycled I mean I never called the method remove() or recycle().

Would the generator connect the containers to the items once again and refresh its DataContext/Bindings even though the containers have been already realized?

Like I mentioned above I never called remove() or recycle() on containers who I generated/realized. But I am interested in what will Generator to do those already created Containers? Would it clear bindinds and connect it again? Would it refresh DataContext?


HwndHost ZIndex

$
0
0

We had to create a Behavior to place a HwnHost inside a border. This is required to use a library that works only in WinForms controls, so by adding HwnHost we could cheat the library.

However, I need to place a control on top of the Border (see sample, please). I made a sample with a button. When running the application, the button always stays behind. How can I make the button stays on top of the HwndHost?

Sample: http://sdrv.ms/19b4tqP


Take a look at WPF FlashMessage
About.me


WPF MVVM: how to detect when CheckBox column of DataGrid is checked/unchecked

$
0
0

I have a View with a Datagrid bound to an ObservableCollection in a ViewModel. One of the Datagrid columns is a DataGridCheckBoxColumn (BTW: as recommended by several posts, I also tried using a CheckBox inside a DataGridTemplateColumn, but that doesn't work either). 

I need to enable a button on the same View (but which is not part of the DataGrid) if any checkbox in the DataGrid is checked, and to disable the button if none are checked.

And this needs to be done declaratively via binding to the ViewModel, without using any (View) code-behind.

Seemed simple enough, until I tried it.

Ideas?

DadCat

Example to populate Combo box

$
0
0

Can someone point me to an example?

I have WPF MVVM program.

on the main screen I have 3 text boxes a combo box and button. When user clicks on the button a popup screen shows up and displays a data grid, when user double clicks on any row the pop up hides and program populates the text boxes with the data from the data grid row.  I am not sure what is the best way to populate the combo box with the data from the database.  I can get the data from the database and populate the combo box in the code behind module, but I don't think that's the correct way for MVVM program, I am coming from Windows Forms world and I am pretty new to WPF and MVVM.

Thank You.


Peter

WPF Copy Paste command Issue

$
0
0

HI,

I have copy paste button like this. Whenever I select some text, this copy button is becoming active. Which is correct behavior.

<Button Name="CopyButton" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" Margin="6,6,3,0"  ToolTip="{x:Static res:Controls.Copy}"  Command="ApplicationCommands.Copy">
       <Image Source="../Resources/Images/GenericEditorActions/Copy.png" x:Name="CopyImage"/>
 </Button>

Now my question is, I have one textbox in my application. Above Copy button should always be in in-active state even I select Text from that textbox. As per req. that textbox should not support any copy paste functionality.

How would I do that?

Pls help

Dee

Advice on drawing images and checking for intersection?

$
0
0

Hello

I need some advice on how to do something in WPF

I have 2 points (a set of X and Y values) that are changing several times a second. I need to draw an image on those points. I also need to check for intersection between the image/rectangle holding the image with other images/rectangles holding images.

I would love to get some advice on where to get started. I tired using rectangles and filling with an imagebrush, but I ran into a plethora of errors and i'm sure there's an easier way!

Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>