xaml - WPF ListView Button - Associate multiple images -


I have a list view in a WPF application that has a button in one of its columns, I connect an image with the button control I want to configure different images for this button based on how I can write XAML in this scenario ???

This is what I already have:

  & lt; Control template x: key = "iconbutton adpriel" target type = "{x: type button}" & gt; & Lt; Grid & gt; & Lt; Image x: name = "myimage" source = "rofile.png" height = "27" width = "65" /> & Lt; Border & gt; & Lt; Content display content = "{TemplateBinding content}" /> & Lt; / Border & gt; & Lt; / Grid & gt; & Lt; / ControlTemplate & gt; & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn Header = "Security" width = "50" & gt; & Lt; GridViewColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Button template = "{StaticResource IconButtonLockSecure}" datacentext = "{binding}" minhite = "20" minwath = "50" /> & Lt; / DataTemplate & gt; & Lt; /GridViewColumn.CellTemplate> & Lt; / GridViewColumn & gt; & Lt; /ListView.View>  

Suppose you have a "button image" in your model that returns returns of ImageSource Is the image for the object, and a property "button content" which gives the content of the button (text or whatever).

Then your control template may be:

  & lt; ControlTemplate X: Key = "IconButtonAddProfile" TargetType = "{x: Type button}" & gt; & Lt; Grid & gt; & Lt; Image x: name = "myimage" source = "{binding button image}" /> & Lt; Border & gt; & Lt; Content display content = "{binding button content}" /> & Lt; / Border & gt; & Lt; / Grid & gt; & Lt; / ControlTemplate & gt;  

Note that you do not need to set up a data context on your button, as it is inherited.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -