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

ListBox SelectedItem sometimes is not visible (scrolling is out of sync)

$
0
0

Hello,

I have a Listbox that is filled with 30,000 elements

<ListBox Name="lbWordlist" 
                 Grid.Row="1" Margin="10"
                 ItemsSource="{Binding Source={StaticResource WordListViewSource}}" 
                 SelectedItem="{Binding Source={StaticResource MainViewModel}, Path=SelectedArticle}"
                 IsSynchronizedWithCurrentItem="True"
                 SelectionChanged="lbWordlist_SelectionChanged" />

I'm tracking history of user clicking items

I have 2 buttons Prev. and Next, these buttons allow user to go back and forward in history.

Prev. and Next button modify SelectedItem property of ListBox

The problem comes up, if user selects random items from ListBox that are very apart from each other (for example user selected some items on top of the list and few items in the bottom of the list).

Prev. and Next button change SelectedItem property, but ListBox is not synced with scroll, selected item is not highlighted and most of the times is not visible to user, as it's outside of ListBox's visible items area.

Is there any way to make ListBox correctly show currently selected item?

Thank You.


how to move textbox.text to onther textbox ?

$
0
0

Hello Freinds 


Hello Freinds 

i want to do something but i don't know how ? 

this main windows i want user to add amount of money in this textbox 

and when he click ( Go) 

this amount will appear in the next windows textbox2 

how i can i do it ?


In WPF MVVM, is it necessary that ViewModel should have Notification capability?

$
0
0

I am doing code review of wpf-mvvm project to know whether the project is adherence to MVVM pattern or not.

So, my question is "should all the ViewModel class have Notification capability?".

How get bitmap handle of a specific icon in a wpf window?

$
0
0

The executable icon I've been given contains many images (with transparent regions). How do I get a bitmap handle of a specific image (e.g. the largest) to pass to a dll? I'm currently using this:

System.Drawing.Icon.ExtractAssociatedIcon(File).ToBitmap.GetHbitmap


Inexplicable Margins in TreeViewItem rendered with custom control template

$
0
0

Hi

I have a TreeView control that uses default System.Windows.Controls.TreeViewItems with their own control template (template XAML see below). The TreeListView exposes GridViewColumns just like a ListView ind GridViewMode. So it has a GridViewRowPresenter inside its template. This GridViewRowPresenter binds to a Columns collections and uses the CellTemplates provided by the 'client' to display the cell content.

Now there is one automatism that i can't explain or modify and that is that for each cell of each column the GridViewRowPresenter creates a ContentPresenter at runtime (which is normal). The ContentPresenter then presents the content of the cell based on the CellTemplate of the GridVilewColumn(s). This is fully OK.

The problem is that the ContentPresenter has its margin set to 6,0,6,0, so there is a gap of 6px on the left of each treeview item!

This is what I'd like to get rid of. I Want a margin of 0.

I cannot see where this margin is defined, Its not in the TreeViewItem template, not in the TreeListView template and also not in the (many) cell DataTemplates. It seems some automatism coming from the GridViewRowPresenter or ContentPresenter default styles, I suppose.

If I modify the Margin to 0 using Snoop, then I get the result i want.

Does anyone know, which style / template is responsible for these horizontal margins and how i could fix them?

Thanks a lot,
Chris

Btw plz have a look at the Control Template and also the
screen shots of Snoop and the App!

The control template is as follows:

<ControlTemplate x:Key="TreeListViewItemTemplate" TargetType="TreeViewItem"><!--  #region TreeViewItem Content  --><StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Orientation="Vertical"                    ><StackPanel Orientation="Horizontal" x:Name="PART_HeaderPanel"><!--  #region "Normal" content  --><Border x:Name="Border"
                        Margin="0"
                        Background="Transparent"
                        BorderBrush="Transparent"
                        BorderThickness="1"
                        CornerRadius="2"><Border x:Name="InnerBorder"
                            BorderBrush="Transparent"
                            BorderThickness="0.5"
                            CornerRadius="1.5"><!--  #region GridViewRowPresenter containing the Columns and their CellTemplates  --><GridViewRowPresenter x:Name="PART_Header"
                                              Grid.Column="1"
                                              Columns="{Binding Path=Columns, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=primitives:TreeListView}}"
                                              Content="{TemplateBinding Header}"<!-- ContentPresenters with Margins generated here , one for each column! -->
                                              Focusable="True" /><!--  #endregion  --></Border></Border><!--  #endregion  --></StackPanel><!--  #region ItemsPresenter containing ItemsPanel to display the sub nodes  --><ItemsPresenter x:Name="ItemsPresenter"
                            Focusable="True"
                            Visibility="Collapsed" /><!--  #endregion  --></StackPanel><ControlTemplate.Triggers><!--  lots of triggers for selection / focus / etc   --></ControlTemplate.Triggers>

Image Snoop:

snoop screen shot: margins in gridviewrowpresenters contentpresenters of treeviewitem control template

Image Margin in app at runtime:

app screen shot: 6px left-margins in gridviewrowpresenters contentpresenters of treeviewitem control template


How to find the center of the ellipse used for an ArcSegment

$
0
0
Hi, I'm trying to get the coordinates of the center of the ellipse used to draw any arbitrary ArcSegment. I started using the code I found here http://www.charlespetzold.com/blog/2008/01/Mathematics-of-ArcSegment.html as was suggested in a different post but it has some issues.  Basically, it finds the center MOST of the time.  But there are some values of Size for which the center exists, yet this algorithm fails to find it.

    // Adjust for different radii and rotation angle
    Matrix matx = new Matrix();
    matx.Rotate(-angleRotation);
    matx.Scale(radiusY / radiusX, 1);
    pt1 = matx.Transform(pt1);
    pt2 = matx.Transform(pt2);

    // Get info about chord that connects both points
    Point midPoint = new Point((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2);
    Vector vect = pt2 - pt1;
    double halfChord = vect.Length / 2;

    // Get vector from chord to center
    Vector vectRotated;

    // (comparing two Booleans here!)
    if (isLargeArc == isCounterclockwise)
        vectRotated = new Vector(-vect.Y, vect.X);
    else
        vectRotated = new Vector(vect.Y, -vect.X);

    vectRotated.Normalize();

    // Distance from chord to center 
    double centerDistance = Math.Sqrt(radiusY * radiusY - halfChord * halfChord);

    // Calculate center point
    Point center = midPoint + centerDistance * vectRotated;


The code above is what I'm using to find the center but for some reason, radiusY is occasionally smaller than halfChord, which makes no sense to me because the transforms should make the ellipse a circle, and the halfchord is half the distance between 2 points on that ellipse, so how can it ever be larger than the radius?

So I guess my question is A) Is there a way to fix what I have or B) is there a better way of finding the center?

Directory file list filtering

$
0
0

I have a menu that consists of the items in a directory.  What I NEED is to filter out a specific file.  The file that I need to NOT show up in this list is called WIPSAdmin... how do I keep that from showing up in the list?  Here is the code:

 string[] directories = Directory.GetDirectories(@"\\srvusadcweb01\wips_test");

            var validDirectories = from string directory in directories
                                   where Path.GetFileNameWithoutExtension(directory) != "WIPSDATA"
                                   select directory;

            foreach (string fileName in validDirectories)
            {
                this.Sites.Add(new Folder() { PathName = fileName });

            }

WPF Frame can not inherit value from parent

$
0
0

Hello

I previosly ask same  question on http://social.msdn.microsoft.com/Forums/en-US/7b86f060-1bf3-407a-8b7f-3c2f75c2b39c/wpf-frame-can-not-inherit-value-from-parent  link.

 If the parent control defines a value for the property "Foreground". The WPF elements inside the Frame will not inherit that properties value.

If I add New Page to frame . then I change theme of window then it is not applying to page of the frame.

Why it is not inheriting from parent?

I need to make it null & again set theme on load of frame.

it cause performance slow of application.

Can you please help me for it?

Ref questions:

http://www.devexpress.com/Support/Center/Question/Details/Q459031

https://connect.microsoft.com/VisualStudio/feedback/details/520355/wpf-frame-control-stops-property-inheritanceI am not getting any proper solution for it.

Download video n code from here

https://drive.google.com/folderview?id=0B_UjcIVA766LZXgyclRxeVFQSFk&usp=sharing

I have created video as well as small Application showing that issue.

Here When I press Add New button New frame added to DockLayoutManager.

So theme is not applied to the child that is page & controls inside the page.

Frame stop theme applying to page.

download

Thanking you in advance..
Regards

Vipul Langalia


Visio Import Image throw error

$
0
0

Hi!
I have a VisioDravingControl in WPF over WindowsFormsHost.
When i try to import any image to Page (ActivePage, etc), Visio throwing exception:

{System.Runtime.InteropServices.COMException (0x86DB0789): An error occurred. Visio is unable to complete importing.

Import code:

_ax.Window.Application.ActivePage.Import(@"D:\1.jpg");

This dont work too http://visguy.com/vgforum/index.php?topic=1629.msg14840#msg14840 (from http://social.msdn.microsoft.com/Forums/en-US/d7696904-5197-48ed-bb1b-d526da8a606c/visio-c-import-images-to-masters).

VBA Macro works fine

Sub Macro1()

   ActivePage.Import ("D:\image.jpg")

End Sub


Why doesn't Textbox support Multibinding on IsEnabled?

$
0
0

Hi all,

I have searched far and wide, but I can't find an answer to what should be a simple question....

Given that I have a converter with this signature:

 
public class multiBoolConverter : IMultiValueConverter
	{
		public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 
{
...
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}

I am trying to implement a textbox that is bound to a value and has it's IsEnabled property bound to 2 values using the above multiConverter.

I have found tons of examples, but none that work with this situation (or at least close enough that I can figure it out.)

Here is the basic textbox:

<TextBox Text = "{Binding thing_no}"><Textbox.IsEnabled><MultiBinding Converter="{StaticResource multiBoolConverter}"
            ConverterParameter="and"><Binding Path="val1" /><Binding Path="val2"/></MultiBinding></Textbox.IsEnabled></TextBox>

And in the resource section of the xaml form I have:

<src:multiBoolConverter x:Key="multiBoolConverter" />

Where src: is tied to the namespace that holds the convert class defined above.

The problem is that when I try this, I get an error that "The attachable property 'IsEnabled' was not found in type 'TextBox'.

Now we all know that Textbox does support IsEnabled (I use it a bunch of other places).  But in this one case, I need to look at 2 bool values in the model, whereas in all the other cases, I just need one.

So the converter code looks at the 2 values and returns true/false.  I pass a parameter so I can specify if I need the values to be compared with an AND or OR.

Any idea what silly little thing I am missing that is causing it not to behave?

Thanks!


me (and yes, I DO mark correct answers)

How to reinitialize crashed mediaelement?

$
0
0

Hi

i am creating a video player which plays video through playlist.

i am testing the application with HD videos like 1080 p. after playing playlist for some 10 hours

suddely there show nothing in the screen. i am using Dispatcher timer for the playlist to switch to next in the list

where timer keepon going but there come nothing in the screen. i think Mediaelement crashed.

to start again i have the close and reopen the application. i there any way that playing the video without reopening the mediaelement.

Thank you


How to implement tooltips for validation errors and still have tooltips?

$
0
0

Hi all,

I think this is a simple question.  I am using a validation approach as detailed here:

http://msdn.microsoft.com/en-us/library/ms752347.aspx#data_validation - where they use a ! colored Red with a tooltip to explain the error.  It works just fine.

However, if I want to have a tooltip with the textbox (whatever), then that overrides the tooltip added by the validation routines.

How can I set up the validationTemplate ControlTemplate and/or textBoxInError Style so that the tooltip is preserved/restored/whatever when the error is correct?  If that is not that easy, then I guess I would want to change the code so that the tooltip is on the red ! instead.'

Here is the base code for those of you leery about clicking on links:

in the resources section of the xaml document:

<ControlTemplate x:Key="validationTemplate"><DockPanel><TextBlock Foreground="Red" FontSize="20">!</TextBlock><AdornedElementPlaceholder /></DockPanel></ControlTemplate><!--<Setter Property="BorderBrush" Value="RoyalBlue" />--><Style x:Key="textBoxInError"    TargetType="{x:Type TextBox}" BasedOn="{StaticResource crimestar-controls-textbox-dataentry}"><Style.Triggers><Trigger Property="Validation.HasError" Value="true"><Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" /></Trigger></Style.Triggers></Style>

  And the implementation of these is:

<TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}"
	Style="{StaticResource textBoxInError}"
	ToolTip="Enter a description of what happened"><TextBox.Text><Binding Path="description"
			UpdateSourceTrigger="PropertyChanged"><Binding.ValidationRules><ExceptionValidationRule /><wpfMisc:dataRequired dataType="string"
			   minLength="3" /></Binding.ValidationRules></Binding></TextBox.Text></TextBox>

Right now, even when there is an error, the tooltip on the textbox takes precidence.  And I don't want to have to bind the tooltip to some property in the View model and then have that get updated when in an invalid state.

As you might notice from the commented out Green boarder setting - I am also trying to figure out how to change the textbox boarder to Red when an error condition exists.

All the examples I can find do this automatically (using <ExceptionValidationRule />) or only add the tooltip.  I am sure there are some good examples, but they are not easy to find.

The other option I am currently trying to evaluate is using an IDataErrorInfo based approach.  I am trying to avoid using any "code behind" the xaml file and only use xaml and the view model.  But will look into this more over the next few days.

Thanks!


me (and yes, I DO mark correct answers)

Create Custom Calendar Using Datagrid

$
0
0

Hello everyone,

I need help in creating a custom calendar using datagrid in WPF.

Please give me some suggestions or samples... 

Hexagon, polygon, select,move and color fill tool create in wpf

$
0
0

hi i already use to draw one codeproject in below link

http://www.codeproject.com/Articles/22776/WPF-DrawTools

its working fine but i have to add color fill, polygon, hexagon  and etc tool what i do , dont have any ideas please give me ideas ..

How to make a window always floating on top

$
0
0
How to make a window always floating on top

No need to worry as many books are not the core and true story


Changing the value in a DataGridComboBox doesn't save

$
0
0

I'm working with the DataGridComboBox for the first time, and found some odd behavior. I'm using entity framework as the source. It is binding fine to the backend data and displaying it fine. I decided, in testing, to change the value of the data associated with the combo box, to another value. When I did a red border appeared around the cell of the DataGridComboBox, so I know something was wrong, but I'm not sure what. I went ahead and tried saving the data. It "saved" without error, but when I reopened the window looking at the same data, the change I made wasn't reflected. Inserting and deleting data works fine, but modifying data doesn't save. What am I doing wrong?

Here's the relevant XAML:

<DataGrid x:Name="aSIIncomeLast30DataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}"
		  Margin="25,80,42,80" RowDetailsVisibilityMode="VisibleWhenSelected" AlternatingRowBackground="Gainsboro"><DataGrid.Columns><DataGridTextColumn x:Name="clientNumberColumn" Binding="{Binding ClientNumber}" Header="Client Number" Width="SizeToHeader" IsReadOnly="True"/><DataGridTextColumn x:Name="caseNumberColumn" Binding="{Binding CaseNumber}" Header="Case Number" Width="SizeToHeader" IsReadOnly="True"/><DataGridTextColumn x:Name="followupColumn" Binding="{Binding Followup}" Header="Followup" Width="SizeToHeader" IsReadOnly="True"/><DataGridComboBoxColumn x:Name="incomeTypeColumn" SelectedValueBinding="{Binding IncomeType}"
								ItemsSource="{Binding Source={StaticResource aSICodesIncomeTypeViewSource}}"
								DisplayMemberPath="IncomeTypeDesc" SelectedValuePath="IncomeType"
								Header="Income Type" Width="SizeToCells"/><DataGridTemplateColumn x:Name="amountEarnedColumn" Header="Amount Earned" Width="SizeToHeader"><DataGridTemplateColumn.CellTemplate><DataTemplate><telerik:RadMaskedCurrencyInput Value="{Binding AmountEarned}" Mask="c5.2" Placeholder=" " /></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn.CellEditingTemplate><DataTemplate><telerik:RadMaskedCurrencyInput Value="{Binding AmountEarned}" /></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn></DataGrid.Columns></DataGrid><Button x:Name="btnSave" Content="Save" HorizontalAlignment="Left" Margin="277,334,0,0" VerticalAlignment="Top" Width="75" ToolTip="Just saves locally" Click="btnSave_Click"/>

And here's the code behind for the saving of the data:

private void btnSave_Click(object sender, RoutedEventArgs e)
{
	try
	{
		asiContext.SaveChanges();
		MessageBox.Show("Saved");
	}
	catch (Exception ex)
	{
		MessageBox.Show(ex.Message);
	}
}


Rod

Permutations and Random

$
0
0

I have written a code block, for testing a set of numbers with a random function

firstly I get a set of 6 numbers from the randomize into a list(of Integer) but test there are no duplicates

I then add the 6 numbers to the group Numbers class to be added to a dictionary of integer and group numbers.

I sum the reject Duplicates as a key for the dictionary to test that no group numbers are the same and add the group numbers

The Problem:

If I run this I get different results in a Data grid

Sometimes I can only get 1 or 2 or 3 or 4 rows but mostly it will just sit there stuck in the loop

I think it is the random function not giving good random numbers combinations and should I not get at least 6 results?

How can I improve this code.


Class MainWindow


   Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded

      ‘ Dim listOfNumbers() As Integer = {1, 2, 3, 4, 5, 6, 7}

       Dim rejectDuplicates As New List(Of Integer)

       Dim listofGroupNumbers As New Dictionary(Of Integer, GroupNumbers)


       Dim finds As Integer = 0


       Do Until finds = 3

           Randomize()

           Dim randomNumber = CStr(Int((7) * Rnd() + 1))


           If Not rejectDuplicates.Contains(CType(randomNumber, Integer)) Then

               rejectDuplicates.Add(randomNumber)

               If rejectDuplicates.Count = 6 Then

                   Dim gn As New GroupNumbers

                   gn.g1 = rejectDuplicates(0)

                   gn.g2 = rejectDuplicates(1)

                   gn.g3 = rejectDuplicates(2)

                   gn.g4 = rejectDuplicates(3)

                   gn.g5 = rejectDuplicates(4)

                   gn.g6 = rejectDuplicates(5)



                   If Not listofGroupNumbers.Keys.Contains(rejectDuplicates.Sum) Then

                       listofGroupNumbers.Add(rejectDuplicates.Sum, gn)

                       rejectDuplicates = New List(Of Integer)

                       finds+= 1

                   End If

               End If


           End If

       Loop


       listGeneratored.ItemsSource = listofGroupNumbers.Values

   End Sub


End Class


Class GroupNumbers

   Public Property g1 As String

   Public Property g2 As String

   Public Property g3 As String

   Public Property g4 As String

   Public Property g5 As String

   Public Property g6 As String

End Class





XamDataChart Customization

$
0
0

I am using Infragistic XamDataChart and need to show UI according to my requirenment. please let me know if the control support these.

1. Need to show series name as there will be multiple series(as Shown in Pic.)
2. Horizontal Zoom bar at the top of the Chart. with fixed size as shown in yellow Box(in Pic). And can drag where user want to zoom. (or XamOvewrviewPlusDetailPane outside the plot area)
3.want to show only boundary values of the DateTimeXAxis as shown in white text at the top of chart.

A image is worth of thousand words.PFA

WPF Databinding usercontrols

$
0
0
some one please help me.
i have a tree control

    <UserControl x:Class="MyApp.Views.MyTree"
                 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" 
                 mc:Ignorable="d" 
                 d:DesignHeight="300" d:DesignWidth="300">
        <Grid >
            <TreeView Name="myTreeControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FFB1D1DA" />
        </Grid>
    </UserControl>
And a grid control

    <UserControl x:Class="MyApp.Views.MyOrder"
                 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" 
                 mc:Ignorable="d" 
                d:DesignHeight="300" d:DesignWidth="300">
        <Grid>
            <DataGrid Name="myGridControl" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Background="#FFF7E5E5" />
        </Grid>
    </UserControl>

I want to put this to some other control 

    <UserControl x:Class="MyApp.Views.ContainerPanel"
                 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:Views="clr-namespace:MyApp.Views"
                 mc:Ignorable="d" 
                 d:DesignHeight="300" d:DesignWidth="300">
        
        
        <Grid Name="grdContainer" >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" ></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*" ></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
    
            <Button Name="btnS" Content="S"  Width="25" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" Height="25" Click="btnS_Click" />
            <Button Name="btnF" Content="F" Width="25"  Grid.Row="0" Grid.Column="2" Height="25" Click="btnF_Click"/>
            <Button Name="btnP" Content="P" Width="25" Height="25" Grid.Row="0" Grid.Column="3" Click="btnP_Click" />
    
            <Views:MyTree  x:Name="FT" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" Grid.ColumnSpan="4"  />
            
            <GridSplitter Name="GS" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Stretch" Height="9" ResizeBehavior="PreviousAndNext" Background="#FFC1B6B6" Grid.ColumnSpan="4" />
    
            <Views:MyOrder  x:Name="PO" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="3" Grid.ColumnSpan="4"  />   
    
    
    
        </Grid>
    </UserControl>

On the button clicks it hide or show or split the screens.
And now I have a main panel. And that hae a tab control. Tab control's itesm shuld be added dynamically. And each tab item is ConatainerPanel. And standing at MainPanel I have to add or remove items to MyTree and MyGrid..
I would like to  use Property PropertyChangedEventHandler for doing these..
Can any one help  me in this?
Can any one give some sample codes?

How to use RelativeSource to Bind DataGridTemplateColumn Width to DataGrid ActualWidth Property

$
0
0

Hello,

I have a DataGrid control, the ActualWidth of which I would like to bind to the one DataGridTemplateColumn's Width property like so.

<DataGrid.Columns><DataGridTemplateColumn Header="File Name" IsReadOnly="True" Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, Path=ActualWidth}"><DataGridTemplateColumn.CellTemplate><DataTemplate><WrapPanel><Image Source="{Binding FileName, Converter={StaticResource localImageSourceConverter}}" Margin="0,0,5,0" HorizontalAlignment="Left" Stretch="None"></Image><TextBlock Text="{Binding FileName}" HorizontalAlignment="Stretch" Margin="0,0,5,0"></TextBlock></WrapPanel></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn></DataGrid.Columns>

 

However, the RelativeSource binding markup extension has no effect.  Is this even possible?

Thank you,

Dan


Viewing all 18858 articles
Browse latest View live


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